Jump to content

paste

From RaySoft

paste is a shell command that joins files horizontally (parallel merging) by writing to standard output lines consisting of the sequentially corresponding lines of each input file, separated by tabs.[1]

Documentation

  • man 1 'paste'

Syntax

paste [PARAMETER ...] [FILE ...]

Parameters

General
The following parameters can be used with all version of paste:
NOTE:
The BSD version only supports the short form (e.g. -d) of these parameters!
-d LIST, --delimiters=LIST
Consecutively use the characters in LIST instead of TAB to separate merged lines. When LIST is exhausted, start again at its beginning.
-s, --serial
Paste the lines of one file at a time rather than one line from each file.
GNU
The following parameters can be used with the GNU version of paste:
-z, --zero-terminated
Delimit items with a zero byte rather than a newline (ASCII LF). I.e., treat input as items separated by ASCII NUL and terminate output items with ASCII NUL. This option can be useful in conjunction with perl -0 or find -print0 and xargs -0 which do the same in order to reliably handle arbitrary file names (even those containing blanks or other special characters).

Examples

Sort a comma separated string ignoring the first char
sed 's/\n//g; s/, */\n/g' <<<'.foo, #bar, -bla' \
| sort --key='1.2' \
| paste --delimiters=',' --serial

Output:

#bar,-bla,.foo

References

  1. Wikipedia contributors. "paste (Unix)." Wikipedia. https://en.wikipedia.org/wiki/Paste_(Unix) (accessed 07.08.2025)