本文介绍了如何将一个文件中的行附加到另一文件的每一行的末尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有两个文件:
cat
dog
baboon
feline
canine
primate
我想在添加空格后在一个文件的末尾附加一个文件的行.我知道一种使用bash中的for循环来执行此操作的方法,但是我认为只有一个命令可以执行这种操作,而我只是不记得了.
I want to append the lines from one file at the end of another file after adding a space. I know a way to do this using a for loop in bash, but I think there is a single command that can do this sort of thing, and I just can't remember it.
输出应如下所示:
cat feline
dog canine
baboon primate
推荐答案
paste --delimiter=' ' file1 file2
注意:结果将被写入stdout.如果要将结果存储在文件中,请使用重定向运算符:
Note: the result will be written to stdout. If you want to store the result in a file, use a redirection operator:
paste --delimiter=' ' file1 file2 > outputfile
运行man paste
有关该命令的更多信息.
Run man paste
for more information about the command.
这篇关于如何将一个文件中的行附加到另一文件的每一行的末尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!