Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cut(C)

grep(C)

pr(C)


 paste(C)                        19 June 1992                        paste(C)


 Name

    paste - merge lines of files

 Syntax

    paste file1 file2 ...

    paste -d list file1 file2 ...

    paste -s [ -d list ] file1 file2 ...

 Description

    In the first two forms, paste concatenates corresponding lines of the
    given input files file1, file2, etc.  It treats each file as a column or
    columns of a table and pastes them together horizontally (parallel merg-
    ing).  It is the counterpart of cat(C) which concatenates vertically,
    that is, one file after the other.  In the last form above, paste sub-
    sumes 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 an
    optionally specified list.  Output is to the standard output, so it can
    be used as the start of a pipe, or as a filter, if ``-'' is used in place
    of a filename.

    The meanings of the options are:

    -d   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.  This option allows replacing the tab character by one or
         more alternate characters (see below).

    list One or more characters immediately following -d replace the default
         tab as the line concatenation character.  The list is used circu-
         larly, that is, when exhausted, it is re-used.  In parallel merging
         (that is, no -s option), 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:  \n (new line), \t (tab),
         \\ (backslash), and \0 (empty string, not a null character).  Quot-
         ing may be necessary, if characters have special meaning to the
         shell (for example, to get one backslash, use -d\\\\ ).

    -s   Merges subsequent lines rather than one from each input file.  Use
         tab for concatenation, unless a list is specified with -d option.
         Regardless of the list, the very last character of the file is
         forced to be a new line.

    -    May be used in place of any filename to read a line from the stan-
         dard input.  (There is no prompting.)

 Examples


    ls | paste -d" " -
                 Lists directory in one column

    ls | paste - - - -
                 Lists directory in four columns

    paste -s -d"\t\n" file
                 Combines pairs of lines into lines

 See also

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

 Diagnostics


    line too long
              Output lines are restricted to 511 characters.

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

 Standards conformance

    paste is conformant with:

    AT&T SVID Issue 2;
    and X/Open Portability Guide, Issue 3, 1989.


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