Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)

User Commands (p - r) paste(1)
EXAMPLES
1. To paste several columns of data together, enter:
paste names places dates > npd
This creates a le named npd that contains the data from names in one column, places in
another, and dates in a third. The columns are separated by tab characters.
npd then contains:
names places dates
rachel New York 28 February
jerzy Warsaw 27 April
mata Nairobi 21 June
michel Boca Raton 27 July
segui Managua 18 November
A tab character separates the name, place, and date on each line.
2. To separate the columns with a character other than a tab (sh only), enter:
paste -d "!@" names places dates > npd
This alternates ! and @ as the column separators. If names, places, and dates are the
same as in Example 1, then npd contains:
rachel!New York@28 February
jerzy!Warsaw@27 April
mata!Nairobi@21 June
michel!Boca Raton@27 July
segui!Managua@18 November
3. To display the standard input in multiple columns, enter:
ls | paste ----
This lists the current directory in four columns. Each - (dash) tells paste to create a
column containing data read from the standard input. The rst line is put in the rst
column, the second line in the second column, ... and then the fth line in the rst
column, and so on.
This is equivalent to the following:
ls | paste -d "\t\t\t\n" -s -
The preceding command line lls the columns across the page with subsequent lines
from the standard input. The -d "\t\t\t\n" denes the character to insert after each
column: a tab character (\t) after the rst three columns, and a newline character (\n)
after the fourth. Without the -d ag, paste -s - displays all of the input as one line with a
tab between each column.
4. To merge the lines of the le names above into one output line, enter:
paste -s names
This results in the following:
rachel jerzy mata michel segui
527188-003 Hewlett-Packard Company 75