#Bash 的 paste 命令
paste [OPTION]... [FILE]...
功能
合并文件的行。
类型
可执行文件(/usr/bin/paste),属于 coreutils。
参数
OPTION选项:-d,--delimiters=LIST- 使用LIST中的字符作为分隔符,而不是制表符-s,--serial- 按文件顺序串行处理-z,--zero-terminated- 以空字符(\0)作为行的结尾,而不是换行符(\n)--help- 显示帮助--version- 显示版本
FILE- 文件列表,如果没有这个参数或指定为-,则读取标准输入
#示例
$ cat 1.txt
A
B
C
$ cat 2.txt
1
2
3
$ cat 3.txt
x
y
z
$ paste 1.txt 2.txt 3.txt # 合并 1.txt 2.txt 3.txt
A 1 x
B 2 y
C 3 z
$ paste -s 1.txt 2.txt 3.txt # 串行处理
A B C
1 2 3
x y z
$ paste -d .- 1.txt 2.txt 3.txt # 依次使用 .- 作为分隔符
A.1-x
B.2-y
C.3-z
#推荐阅读
#手册
PASTE(1) User Commands PASTE(1)
NAME
paste - merge lines of files
SYNOPSIS
paste [OPTION]... [FILE]...
DESCRIPTION
Write lines consisting of the sequentially corresponding lines from
each FILE, separated by TABs, to standard output.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options
too.
-d, --delimiters=LIST
reuse characters from LIST instead of TABs
-s, --serial
paste one file at a time instead of in parallel
-z, --zero-terminated
line delimiter is NUL, not newline
--help display this help and exit
--version
output version information and exit
AUTHOR
Written by David M. Ihnat and David MacKenzie.
REPORTING BUGS
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
COPYRIGHT
Copyright © 2023 Free Software Foundation, Inc. License GPLv3+: GNU
GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
Full documentation <https://www.gnu.org/software/coreutils/paste>
or available locally via: info '(coreutils) paste invocation'
GNU coreutils 9.4 April 2024 PASTE(1)