使用awk在同一行上链接和文本

时间:2022-07-29 16:06:50

I have a file that looks like, where the web address is on the second line:

我有一个看起来像的文件,网址在第二行:

Code inbash used to create new.txt

代码inbash用于创建new.txt

while read A B
do
    echo "https://www.xxxx.com/add_2_cart.php?catno=${A}&storage=lyophilized&rxns=100&num=1&test=mixed&format=tube"
done < inputfile > new.txt

File 1 Contents of new.txt

文件1 new.txt的内容

PXL-A0000005 DTE3504500000005 
web address
PXL-A0000007 DTE3504500000007 
web address

I am trying to reformat that file using:

我正在尝试使用以下方法重新格式化该文件:

 awk '1;getline <"link.txt"' new.txt > newfile.txt

but getting the same output and I am not sure why or how to output each on one line: Thank you :)

但获得相同的输出,我不知道为什么或如何输出每一行:谢谢:)

Desired output

PXL-A0000005 DTE3504500000005 web address
PXL-A0000007 DTE3504500000007 web address

1 个解决方案

#1


Do you have to use awk ? paste should do the job :

你必须使用awk吗?粘贴应该做的工作:

 paste -s -d' \n' new.txt

Results:

 PXL-A0000005 DTE3504500000005  web address
 PXL-A0000007 DTE3504500000007  web address

#1


Do you have to use awk ? paste should do the job :

你必须使用awk吗?粘贴应该做的工作:

 paste -s -d' \n' new.txt

Results:

 PXL-A0000005 DTE3504500000005  web address
 PXL-A0000007 DTE3504500000007  web address