Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cut(1)

grep(1)

/egrep(1)

/fgrep(1)

join(1)

pr(1)

paste(1)  —  Commands

OSF

NAME

paste − Joins corresponding lines of several files or subsequent lines in one file

SYNOPSIS

paste [ -dlist ] [-s] file ... 

The paste command reads input files (or standard input if you specify a - (dash) instead of a filename), joins corresponding lines, and writes the result to standard output. 

FLAGS

-dlistReplaces the delimiter that separates lines in the output (tab by default) with one or more characters from list.  If list contains more than one character, then the characters are repeated in order until the end of the output.  In parallel merging, the lines from the last file always end with a newline character, instead of one from list.  The following special characters can be used in list:

\nNewline character

\tTab

\\Backslash

\0Empty string (not a null character)

cAn extended character

You must quote characters that have special meaning to the shell.

-sMerges all lines from each input file into one line of output (serial merging).  With this flag, paste works through one entire file before starting on the next.  When it finishes merging the lines in one file, it forces a newline and then merges the lines in the next input file, continuing in the same way through the remaining input files, one at a time.  A tab separates the input lines unless you use the -d flag.  Regardless of the list, the last character of the output is a newline character. 

DESCRIPTION

Without a flag, or with the -d flag, paste treats each file as a column and joins them horizontally with a tab character by default (parallel merging). 

With the -s flag, paste combines all lines of each input file into one output line (serial merging).  These lines are joined with the tab character by default. 

Output lines are restricted to 511 bytes. 

Note that the output of pr -t -m is similar to that of paste, but creates extra spaces, tabs, and lines for an enhanced page layout. 

EXAMPLES

     1.To paste several columns of data together, enter:

paste  names  places  dates  > npd

This creates a file 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:

namesplacesdates
 rachelNew York28 February
jerzyWarsaw27 April
mataNairobi21 June
michelBoca Raton27 July
seguiManagua18 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 first line is put in the first column, the second line in the second column, ... and then the fifth line in the first column, and so on.  This is equivalent to

ls | paste -d"\t\t\t\n"  -s  -

which fills the columns across the page with subsequent lines from the standard input.  The -d\t\t\t\n defines the character to insert after each column: a tab character (\t) after the first three columns, and a newline character (\n) after the fourth.  Without the -d flag, paste -s - displays all of the input as one line with a tab between each column. 

     4.To merge the lines of the file names above into one output line, enter:

paste -s names

This results in:

racheljerzymatamichelsegui

RELATED INFORMATION

Commands:  cut(1), grep(1)/egrep(1)/fgrep(1), join(1), pr(1). 

OSF/1 User’s Guide. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026