Linux常用基本命令(paste)
Posted ghostwu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux常用基本命令(paste)相关的知识,希望对你有一定的参考价值。
paste命令
作用:合并文件
格式:
paste [option] [file]
1,把两个文件的内容,按行合并
[email protected]:~/linux/paste$ ls ghostwu1.txt ghostwu2.txt [email protected]:~/linux/paste$ cat ghostwu1.txt 1 2 3 4 5 6 [email protected]:~/linux/paste$ cat ghostwu2.txt hi hello nihao 你好啊 how are you fine think you [email protected]:~/linux/paste$ paste ghostwu1.txt ghostwu2.txt 1 hi 2 hello 3 nihao 4 你好啊 how are you 5 fine think you 6 [email protected]:~/linux/paste$
-d 指定分隔符
[email protected]:~/linux/paste$ paste -d : ghostwu1.txt ghostwu2.txt 1:hi 2:hello 3:nihao 4:你好啊 :how are you 5:fine think you 6:
-s 每个文件占用一行
[email protected]:~/linux/paste$ paste -s ghostwu1.txt 1 2 3 4 5 6 [email protected]:~/linux/paste$ paste -s ghostwu2.txt hi hello nihao 你好啊 how are you fine think you [email protected]:~/linux/paste$ paste -s ghostwu1.txt ghostwu2.txt 1 2 3 4 5 6 hi hello nihao 你好啊 how are you fine think you
把一个文件的奇偶行,用=号会换行符号连接
[email protected]:~/linux/paste$ cat account.txt hello abc123 hello2 haha123 baby baby123 [email protected]:~/linux/paste$ paste -sd ‘=\n‘ account.txt > account2.txt [email protected]:~/linux/paste$ cat account2.txt hello=abc123 hello2=haha123 baby=baby123
以上是关于Linux常用基本命令(paste)的主要内容,如果未能解决你的问题,请参考以下文章
Linux 150命令之查看文件及内容处理命令 more split file diff paste wc dps2unix