linux paste tab,每天学一个 Linux 命令(37):paste

29f6864d31bcb8d42a5ef8ea3982b078.png

命令简介

paste 命令用于并排显示多个文件的相应行,将多个文件按列合并。

语法格式paste [选项] [文件]

paste [OPTION] [FILE]

选项说明-d  #指定分隔符来取代默认分隔符(TAB分隔符)

-s  #串列进行而非平行处理

--help  #显示帮助信息

--version  #显示版本信息

应用举例

并排显示两个文件的内容,[root@centos7 testdir]# paste mingongge1.txt mingongge2.txt

1111 11 111111 1 111 1 1 11 head1

22222222222 222 2222 22 2 2 2 head2

33333333333 333333 3333 333 33 head3

444444444444 444 444444444 head4

1

2

3

4

paste 命令其他用法[root@centos7 testdir]# paste mingongge1.txt

1111 11 111111 1 111 1 1 11

22222222222 222 2222 22 2 2 2

33333333333 333333 3333 333 33

444444444444 444 444444444

1

2

3

4

#连接文件中的所有行

[root@centos7 testdir]# paste -s mingongge1.txt

1111 11 111111 1 111 1 1 11 22222222222 222 2222 22 2 2 2 33333333333 333333 3333 333 33 444444444444 444 444444444 1 2 3 4

#使用指定分隔符连接所有行

[root@centos7 testdir]# paste -d, -s mingongge1.txt

1111 11 111111 1 111 1 1 11,22222222222 222 2222 22 2 2 2,33333333333 333333 3333 333 33,444444444444 444 444444444,1,2,3,4

[root@centos7 testdir]# paste -d[] -s mingongge1.txt

1111 11 111111 1 111 1 1 11[22222222222 222 2222 22 2 2 2]33333333333 333333 3333 333 33[444444444444 444 444444444]1[2]3[4

[root@centos7 testdir]# paste -d/ -s mingongge1.txt

1111 11 111111 1 111 1 1 11/22222222222 222 2222 22 2 2 2/33333333333 333333 3333 333 33/444444444444 444 444444444/1/2/3/4

#查看 paste 命令版本

[root@centos7 testdir]# paste --version

paste (GNU coreutils) 8.22

Copyright (C) 2013 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later .

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

Written by David M. Ihnat and David MacKenzie.

paste 合并两个文件,或者添加行[root@centos7 testdir]# cat mingongge1.txt

1111 11 111111 1 111 1 1 11

22222222222 222 2222 22 2 2 2

33333333333 333333 3333 333 33

444444444444 444 444444444

1

2

3

4

[root@centos7 testdir]# cat mingongge2.txt

head1

head2

head3

head4

[root@centos7 testdir]# paste -d 'n' mingongge1.txt mingongge2.txt

1111 11 111111 1 111 1 1 11

head1

22222222222 222 2222 22 2 2 2

head2

33333333333 333333 3333 333 33

head3

444444444444 444 444444444

head4

1

2

3

4

[root@centos7 testdir]# paste -d 'r' mingongge1.txt mingongge2.txt

head111 111111 1 111 1 1 11

head2222222 222 2222 22 2 2 2

head3333333 333333 3333 333 33

head44444444 444 444444444

1

2

3

4

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值