paste -- merge lines of files


paste [ [ -s ] -d list ] file ...


paste concatenates corresponding lines of the given input files. It treats each file as a column of a table and joins them together horizontally (parallel merging). It is the counterpart of cat(C) which concatenates files vertically, that is, one file after the other.

If the -s option is specified, paste subsumes the function of an older command with the same name by combining subsequent lines of the input file (serial merging). In all cases, lines are ``glued'' together with the tab character, or with characters from a list specified using the -d option.

Output is to the standard output, so paste can be used as the start of a pipe. If ``-'' is used in place of a filename, paste reads a line from the standard input. (There is no prompting.)

paste understands the following options:

-d list
Replace the tab as the line concatenation character by one or more alternate characters specified in list. (Without this option, the new line characters of each but the last file (or last line in case of the -s option) are replaced by a tab character.)

The list is used circularly, that is, when exhausted, it is re-used. In parallel merging (-s not specified), the lines from the last file are always terminated with a new line character, not from the list. The list may contain the special escape sequences:




empty string, not a null character

Quoting may be necessary, if characters have special meaning to the shell (for example, to get one backslash, use -d\\\\).

Merge subsequent lines rather than one from each input file. Use tab for concatenation, unless a list is specified with the -d option. Regardless of the list, the very last character of the file is forced to be a newline.
paste recognizes the option -- as the option delimiter.


line too long
Output lines are restricted to 511 characters.

too many files
Except for the -s option, no more than 12 input files may be specified.


List a directory in four columns:

ls | paste - - - -

Combine pairs of lines in a file:

paste -s -d "\t\n" file

See also

cut(C), grep(C), pr(C)

Standards conformance

paste is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003