Shell 将两个文件按列合并

file1. 

1 2 

2 3 

3 4 

4 5 

5 6 

file2. 

a b 

b c 

c d 

d e 

e f 

需要把file2的第二列合并到file1,使File1并成三列. 



第一种方法:paste 

paste -d " " file1 file2 
第二种方法:awk 

awk 'NR==FNR{a[i]=$0;i++}NR>FNR{print a[j]" "$0;j++}' file1 file2
原文地址:https://www.cnblogs.com/chenhuan001/p/6674326.html