0
dog
cat
spider
donkey
文件2
Bone
Mushroom
bug
grass
輸出所需的行
文件3
dog Bone
cat Mushroom
spider bug
donkey grass
dog
cat
spider
donkey
文件2
Bone
Mushroom
bug
grass
輸出所需的行
文件3
dog Bone
cat Mushroom
spider bug
donkey grass
合併文件的行的合適的工具是paste
paste file1 file2 > file3
輸出:
dog Bone
cat Mushroom
spider bug
donkey grass
通過awk,
awk 'FNR==NR{a[FNR]=$0;next}{print a[FNR],$0}' file1 file2 | column -t > file3
實施例:
$ awk 'FNR==NR{a[FNR]=$0;next}{print a[FNR],$0}' file1 file2 | column -t
dog Bone
cat Mushroom
spider bug
donkey grass