输入文件:
col01 20083d70-1bf0-40f4-9df9-6247d587c085 text text
col02 d233d76d-e60d-442e-9b44-f0e1dc9ebefb text text
col03 20083d70-1bf0-40f4-9df9-6247d587c085 text text
col04 20083d70-1bf0-40f4-9df9-6247d587c085 text text
col05 b26063fa-93e4-414d-82f2-7c2924c81cc6 text text
col06 dc3e2f9b-05bf-49b4-a63e-c4bc09524eb3 text text
col07 d9f5cf1d-a8f9-488d-b088-b7ad00b67ec6 text text
col08 b26063fa-93e4-414d-82f2-7c2924c81cc6 text text
col09 d9a558ff-494a-4ada-8ec2-e9b2f9178599 text text
col10 b26063fa-93e4-414d-82f2-7c2924c81cc6 text text
col11 b26063fa-93e4-414d-82f2-7c2924c81cc6 text text
col12 4d78f804-18f6-4cc8-98a3-c4aedc60aebf text text
col13 0fe487fe-2ff2-4ca4-adf8-de3c19115dde text text
col14 581207a4-f4a5-4373-806b-0e1f7c298bb1 text text
参考文件:
0fe487fe-2ff2-4ca4-adf8-de3c19115dde group1
20083d70-1bf0-40f4-9df9-6247d587c085 group2
4d78f804-18f6-4cc8-98a3-c4aedc60aebf group3
581207a4-f4a5-4373-806b-0e1f7c298bb1 group4
b26063fa-93e4-414d-82f2-7c2924c81cc6 group5
d233d76d-e60d-442e-9b44-f0e1dc9ebefb group6
d9a558ff-494a-4ada-8ec2-e9b2f9178599 group7
d9f5cf1d-a8f9-488d-b088-b7ad00b67ec6 group8
dc3e2f9b-05bf-49b4-a63e-c4bc09524eb3 group9
预期输出:
col01 20083d70-1bf0-40f4-9df9-6247d587c085(group2) text text
col02 d233d76d-e60d-442e-9b44-f0e1dc9ebefb(group6) text text
col03 20083d70-1bf0-40f4-9df9-6247d587c085(group2) text text
col04 20083d70-1bf0-40f4-9df9-6247d587c085(group2) text text
col05 b26063fa-93e4-414d-82f2-7c2924c81cc6(group5) text text
col06 dc3e2f9b-05bf-49b4-a63e-c4bc09524eb3(group9) text text
col07 d9f5cf1d-a8f9-488d-b088-b7ad00b67ec6(group8) text text
col08 b26063fa-93e4-414d-82f2-7c2924c81cc6(group5) text text
col09 d9a558ff-494a-4ada-8ec2-e9b2f9178599(group7) text text
col10 b26063fa-93e4-414d-82f2-7c2924c81cc6(group5) text text
col11 b26063fa-93e4-414d-82f2-7c2924c81cc6(group5) text text
col12 4d78f804-18f6-4cc8-98a3-c4aedc60aebf(group3) text text
col13 0fe487fe-2ff2-4ca4-adf8-de3c19115dde(group1) text text
col14 581207a4-f4a5-4373-806b-0e1f7c298bb1(group4) text text
现在我可以通过循环实现这sed -i
一点while
:
$ cat reference|while read a b;do sed -i s/"$a"/"$a($b)"/ input;done
是否可以以更简单的方式完成,仅使用 awk 而不使用 while 循环,在单个 awk 命令处理中使用输入和参考文件仅更改第二列中的值?