| paste | |
|---|---|
| Original authors | AT&T Bell Labs |
| Developer | GNU Project |
| Initial release | 1973 (as part ofVersion 4 Unix) |
| Written in | C |
| Operating system | Unix, Unix-like (Linux, macOS) |
| Platform | POSIX-compliant systems,Cross-platform |
| Type | Command-line utility |
| License | coreutils:GPL v3+ |
| Website | GNU manual |
paste is ashell command that joinsfiles horizontally (parallel merging) by writing tostandard output lines consisting of the sequentially corresponding lines of each input file, separated bytabs.
The command reads each specified input file line-by-line. For each set of input lines, the command outputs a line formatted as the concatenation of the input files' lines separated by a tab character. If the content of a file runs out, the command will use an empty string for the file. As such, the number of output lines will equal the number of lines of the file with the most lines. Some implementations support using a fixed string (such as "NA") when a files content is exhausted before the others.
A sequence of empty records at the bottom of a column of the output stream may or may not have been present in the input file corresponding to that column as explicit empty records, unless you know the input file supplied all rows explicitly (e.g. in the canonical case where all input files all do indeed have the same number of lines).
The command accepts the following options:
-d|--delimitersdelimiters, specifies a list ofdelimiters to use instead of tabs for separating consecutive values on a single line. Each delimiter is used in turn, and when the list has been exhausted,paste begins again at the first delimiter.-s|--serial, select to append in serial rather than in parallel; that is, horizontal rather than vertical.The command was developed forUnix atBell Labs by Gottfried W. R. Luderer.[1][2] The implementation bundled inGNUcoreutils was written by David M. Ihnat and David MacKenzie.[3] The command is available forWindows viaUnxUtils.[4]
For the following examples,names.txt is a plain-text file that contains:
Mark SmithBobby BrownSue MillerJenny Igotit
numbers.txt is another plain-text file that contains:
555-1234555-9876555-6743867-5309
The following command joins the two files.
$pastenames.txtnumbers.txtMark Smith555-1234Bobby Brown555-9876Sue Miller555-6743Jenny Igotit867-5309
When invoked with the--serial option (-s on BSD or older systems), the files are joined horizontally:
$paste--serialnames.txtnumbers.txtMark SmithBobby BrownSue MillerJenny Igotit555-1234555-9876555-6734867-5309
The use of the--delimiters option (-d on BSD or older systems) is illustrated in the following example:
$paste--delimiters.names.txtnumbers.txtMark Smith.555-1234Bobby Brown.555-9876Sue Miller.555-6743Jenny Igotit.867-5309
Sum the numbers from 1 to 100:
$seq1100|paste-d+-s|bc5050