paste 合并文件

1.命令功能

paste  用于合并文件的列,把每个文件以列对列的方式,一列列地加以合并。

2.语法格式

paste  option  file

参数选项

参数

参数说明

-d

指定间隔符合并文件(默认是空格为间隔符)

-s

一次合并一个文件(串列进行而非平行处理)

3.使用范例

准备工作

[root@localhost test]# cat test1

123456

789100

112233

445566

[root@localhost test]# cat test2

abcdef

ghilmn

aabbcc

ddeeff

范例1 合并文件

[root@localhost test]# paste test1 test2

123456  abcdef

789100  ghilmn

112233  aabbcc

445566  ddeeff

范例2 通过星(*)号合并文件

[root@localhost test]# paste -d "*" test1 test2

123456*abcdef

789100*ghilmn

112233*aabbcc

445566*ddeeff

范例3  -s参数使用

[root@localhost test]# paste -s test2 

abcdef  ghilmn  aabbcc  ddeeff

[root@localhost test]# paste -s test2 test1    

abcdef  ghilmn  aabbcc  ddeeff

123456  789100  112233  445566

[root@localhost test]# paste -d "^" -s test2 test1

abcdef^ghilmn^aabbcc^ddeeff

123456^789100^112233^445566
原文地址:https://www.cnblogs.com/joechu/p/8947521.html