linux 中 paste、cat 结合管道符合并方向调整

发布时间 2023-12-31 18:11:08作者: 小鲨鱼2018

 

001、paste

[root@pc1 test1]# ls
a.txt  b.txt
[root@pc1 test1]# cat a.txt                  ## 测试文件
01      02      03      04      05
06      07      08      09      10
[root@pc1 test1]# cat b.txt                  ## 测试文件
1
2
[root@pc1 test1]# cut -f 2 a.txt
02
07
[root@pc1 test1]# cut -f 2 a.txt | paste - b.txt       ## 合并1
02      1
07      2
[root@pc1 test1]# cut -f 2 a.txt | paste b.txt -        ## 调整合并方向
1       02
2       07

 

002、cat

[root@pc1 test1]# ls
a.txt  b.txt
[root@pc1 test1]# cat a.txt                          ## 测试文件
01      02      03      04      05
06      07      08      09      10
[root@pc1 test1]# cat b.txt                          ## 测试文件
1
2
[root@pc1 test1]# tail -n 1 a.txt | cat - b.txt      ## 合并1
06      07      08      09      10
1
2
[root@pc1 test1]# tail -n 1 a.txt | cat b.txt -       ## 调整合并方向
1
2
06      07      08      09      10

 。