paste

作者: cutelittlePanda | 来源:发表于2018-03-15 19:13 被阅读0次

    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

    $

    相关文章

      网友评论

          本文标题:paste

          本文链接:https://www.haomeiwen.com/subject/jorfqftx.html