通过管道在bash合并文件 [英] merge file in bash by pipe
本文介绍了通过管道在bash合并文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来的Linux,我有一个简单的问题。结果
我的任务结果
我有两个文件,A.TXT和B.txt结果
A.TXT结果
1结果
2结果
3结果
B.txt结果
4结果
5结果
6结果
我想有一个结果为:结果
C.txt结果
1 4结果
2 5结果
3 6结果
结果
我的提问结果
基本上我可以使用脚本来做到这一点,但我想看看我是否可以管做在bash?
I am new to linux and I have a simple question.
My task
I have two files, A.txt and B.txt
A.txt
1
2
3
B.txt
4
5
6
I want to have a outcome as:
C.txt
1 4
2 5
3 6
My question
Basically I can use a script to do this, but I would like to see if I can do this in bash with pipe?
推荐答案
您可以使用粘贴
命令:
paste -d' ' A.txt B.txt > C.txt
测试:
$ head *.txt
==> A.txt <==
1
2
3
==> B.txt <==
4
5
6
$ paste -d' ' A.txt B.txt > C.txt
$ cat C.txt
1 4
2 5
3 6
这篇关于通过管道在bash合并文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文