2014-09-05 17 views

回答

2

合并文件的行的合适的工具是paste

paste file1 file2 > file3 

输出:

dog  Bone 
cat  Mushroom 
spider bug 
donkey grass 
1

通过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 
相关问题