paste -d : file1 file2 > file3, 把两个文件的内容按列合并,与cat命令直接将不同文件按照先后顺序接起来不同,paste可以非常快速的将两个文件中的内容按照文件顺序从左往右排起来
-d delimiter, 分隔符,只能指定一个;
$ echo 'a
> b
> c
> d
> e
> f
> g' > b.txt
$ cat b.txt
a
b
c
d
e
f
g
$ paste a.txt b.txt > c.txt
$ cat c.txt
1 a
3 b
5 c
7 d
9 e
11 f
g
$ paste a.txt b.txt
1 a
3 b
5 c
7 d
9 e
11 f
g
$ paste -d : a.txt b.txt
1:a
3:b
5:c
7:d
9:e
11:f
:g
$ echo '0' >> a.txt
$ paste -d : a.txt b.txt
1:a
3:b
5:c
7:d
9:e
11:f
0:g
$ paste -d : a.txt b.txt > d.txt
$ cat d.txt
1:a
3:b
5:c
7:d
9:e
11:f
0:g
$ paste a.txt b.txt -s //-s , 删除换行符
1 3 5 7 9 11 0
a b c d e f g
$ paste -d : a.txt b.txt -s
1:3:5:7:9:11:0
a:b:c:d:e:f:g
$