gpt4 book ai didi

excel - 将多行从一个文件附加到另一个文件

转载 作者:行者123 更新时间:2023-12-04 21:14:04 24 4
gpt4 key购买 nike

大家好,

我有两个具有相同行数的文件(确切地说是 503 行),我想将一个文件的内容附加到它们前面的另一个文件中,没有任何空格或制表符。让我们考虑输入文件的内容是:

一个.txt

C:\Users\Desktop.VG\New-folder\?filename=
C:\Users\Desktop.VG\New-folder\?filename=
C:\Users\Desktop.VG\New-folder\?filename=
C:\Users\Desktop.VG\New-folder\?filename=
C:\Users\Desktop.VG\New-folder\?filename=

两个.txt
one
val_ilu_girl
pacmanhall
four_stars
squares3

现在我想要这样:
C:\Users\Desktop.VG\New-folder\?filename=one
C:\Users\Desktop.VG\New-folder\?filename=val_ilu_girl
C:\Users\Desktop.VG\New-folder\?filename=pacmanhall
C:\Users\Desktop.VG\New-folder\?filename=four_stars
C:\Users\Desktop.VG\New-folder\?filename=squares3

Is there a way to do this using anything from SED GREP AWK to EXCEL Notepadd++ etc.?



提前致谢...!

最佳答案

请您尝试以下操作。

awk 'FNR==NR{a[FNR]=$0;next} {print $0 a[FNR]}'  two.txt one.txt

解释:为上面的代码添加解释。
awk '                   ##Starting awk program here.
FNR==NR{ ##Checking condition FNR==NR which will be TRUE when first Input_file is being read.
a[FNR]=$0 ##Creating an array named a whose index is FNR and value is current line.
next ##next will skip all further statements from here.
} ##Closing BLOCK for FNR==NR condition here.
{ ##These statements will be executed when 2nd Input_file is being read.
print $0 a[FNR] ##Printing current line along with array a value with index of FNR.
}
' two.txt one.txt ##Mentioning Input_file names here.

关于excel - 将多行从一个文件附加到另一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59010675/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com