测试数据:
[xiluhua@vm-xiluhua][~]$ cat msn.txt
aaa bbb
bbb ccc
ccc ddd
bbb eee
aaa ccc
bbb sss [xiluhua@vm-xiluhua][~]$ cat msn.bk
AAA BBB
BBB CCC
CCC DDD
BBB EEE
AAA CCC
BBB SSS
[xiluhua@vm-xiluhua][~]$ cat msn3.bk
aaa bbb
BBB CCC
CCC DDD
BBB EEE
AAA CCC
BBB SSS
默认方式合并:
[xiluhua@vm-xiluhua][~]$ paste msn.txt msn.bk
aaa bbb AAA BBB
bbb ccc BBB CCC
ccc ddd CCC DDD
bbb eee BBB EEE
aaa ccc AAA CCC
bbb sss BBB SSS
-d选项,指定合并时使用的分隔符:
[xiluhua@vm-xiluhua][~]$ paste -d "|" msn.txt msn.bk
aaa bbb|AAA BBB
bbb ccc|BBB CCC
ccc ddd|CCC DDD
bbb eee|BBB EEE
aaa ccc|AAA CCC
bbb sss|BBB SSS
-s选项,将每个文件的内容合并成一行后,进行比较:
[xiluhua@vm-xiluhua][~]$ paste -s msn.txt msn.bk msn3.bk
aaa bbb bbb ccc ccc ddd bbb eee aaa ccc bbb sss
AAA BBB BBB CCC CCC DDD BBB EEE AAA CCC BBB SSS
aaa bbb BBB CCC CCC DDD BBB EEE AAA CCC BBB SSS
将文件内容由一列转换为两列:
[xiluhua@vm-xiluhua][~]$ paste - - < msn.txt
aaa bbb bbb ccc
ccc ddd bbb eee
aaa ccc bbb sss
将文件内容由一列转换为两列,并使用冒号分隔:
[xiluhua@vm-xiluhua][~]$ paste -d ":" - - < msn.txt
aaa bbb:bbb ccc
ccc ddd:bbb eee
aaa ccc:bbb sss
-