Skip to content

Instantly share code, notes, and snippets.

@liujingyu
Last active June 16, 2017 08:37
Show Gist options
  • Save liujingyu/e313fa846f58415db4d492a69f9f67bf to your computer and use it in GitHub Desktop.
Save liujingyu/e313fa846f58415db4d492a69f9f67bf to your computer and use it in GitHub Desktop.
Linux:CMD

paste 逐行合并两个文件

  • -d 指定两个文件合并后每行之间的分隔符,如:
  • -d " " 以空格作为行之间的分隔符。
  • -d "\t" 以tab键作为行之间的分隔符。
  • -d "任意字符" 以"任意字符"作为行之间的分隔符。
  • -s paste one file at a time instead of in parallel

将合并后的行导入新文件中:

paste -d " " a b > c

操作示例

[root@localhost aaa]# more a
1
2
3
[root@localhost aaa]# more b
a
b
c
[root@localhost aaa]# paste a b
1   a
2   b
3   c
[root@localhost aaa]# paste -d " " a b
1 a
2 b
3 c
[root@localhost aaa]# paste -d ":" a b
1:a
2:b
3:c
[root@localhost aaa]# paste -s a b
1   2   3
a   b   c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment