使用shell脚本组合2个文件的列
我有一个使用shell脚本组合2个文件的列,shell,join,command-line,Shell,Join,Command Line,我有一个 A B C D E F 和2.txt H J N 如何将第三列添加到one.txt,如: A B H C D J E F N 我想使用shell脚本执行此操作。。有什么命令可以帮助吗?粘贴到救援中-d代表“delimiter”,我将其设置为“space” 如果要将结果存储在one.txt中,可以将其保存在临时文件中,然后将其替换为one.txt: $ paste -d' ' one.txt two.txt > temp && mv temp one.txt
A B
C D
E F
和2.txt
H
J
N
如何将第三列添加到one.txt,如:
A B H
C D J
E F N
我想使用shell脚本执行此操作。。有什么命令可以帮助吗?
粘贴到救援中-d
代表“delimiter”,我将其设置为“space”
如果要将结果存储在one.txt
中,可以将其保存在临时文件中,然后将其替换为one.txt
:
$ paste -d' ' one.txt two.txt > temp && mv temp one.txt
+1.将粘贴
和mv
命令与&
一起使用--如果粘贴失败,则不希望用垃圾覆盖文件reason@glennjackman,非常聪明的建议,刚刚更新了我的答案。谢谢
$ paste -d' ' one.txt two.txt > temp && mv temp one.txt