Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ paste(1) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

grep, egrep, fgrep

cut

pr



PASTE(1,C)                  AIX Commands Reference                   PASTE(1,C)



-------------------------------------------------------------------------------
paste



PURPOSE

Merges the lines of several files or subsequent lines in one file.

SYNTAX


         +-- -d"\t" ---+
paste ---| +---------+ |-- file1 -- file2 --|
         +-| -s      |-+          ^       |
          ^| -d list ||           +-------+
          |+---------+|
          +-----------+

paste -- -s -- file --|
             ^      |
             +------+


DESCRIPTION

The paste command reads input file (standard input if you specify a - as a file
name), concatenates the corresponding lines of the given input files, and
writes the resulting lines to standard output.  Output lines are restricted to
511 characters.  If you have selected a language (through the LANG environment
variable) that supports multibyte characters, the 511-character limit may be
reduced by as much as 50%, depending on the character code set being used.

Without a flag, or with the -d flag, the paste command treats each file as a
column and joins them horizontally with a tab character by default (parallel
merging).  You can think of this command as the counterpart of the cut command
(see page cut-1), which concatenates files vertically (one file after
another).

With the -s flag, the paste command combines subsequent lines of an input file
(serial merging).  These lines are joined with the tab character by default.

Note:  The action of the pr -t -m command is similar to that of the paste
       command, but creates extra blanks, tabs and lines which result in an
       attractive page layout.

FLAGS

-d list    Changes the delimiter that separates corresponding lines in the
           output with one or more characters in list (the default is a tab).
           If more than one character is in list, the characters are repeated
           in order until the end of the output.  In parallel merging, the



Processed November 8, 1990        PASTE(1,C)                                  1





PASTE(1,C)                  AIX Commands Reference                   PASTE(1,C)



           lines from the last file always end with a new-line character
           instead of a character from list.

           The following special characters can also be used in list:

           \n      New-line character
           \t      Tab
           \\      Backslash
           \0      Empty string (not a null character).
           c       An extended character.

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

-s         Merges subsequent lines from the first file horizontally.  With this
           flag, the paste command works through one entire file before
           starting on the next.  When it finishes merging the lines in one
           file, it forces a new line 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 lines unless you use the
           -d flag.  Regardless of the list, the last character of the file is
           forced to be a new-line character.

EXAMPLES

  1. To join several columns of data together:

      paste  names  places  dates  > npd

    This command creates a file named "npd" that contains the data from the
    files "names", "places", and "dates".  If "names", "places", and "dates"
    look like this:

    +-----------+------------+-----------+
    |names      | places     | dates     |
    +-----------+------------+-----------+
    |           |            |           |
    |"          | "          | "         |
    |rachel     | New York   | February 5|
    |elvis      | Austin     | March 13  |
    |mark       | Chicago    | June 21   |
    |marsha     | Boca Raton | July 16   |
    |scott "    | Seattle "  | November 4|"
    |           |            |           |
    +-----------+------------+-----------+

    then the file "npd" contains:

      rachel  New York      February 5
      jerry   Austin   March 13
      mark    Chicago  June 21
      marsha  Boca Raton    July 16
      scott   Seattle November 4



Processed November 8, 1990        PASTE(1,C)                                  2





PASTE(1,C)                  AIX Commands Reference                   PASTE(1,C)




    A tab character separates the name, place, and date on each line.  As in
    this example, the columns do not always line up because the tab stops are
    set at every eighth column.

  2. To separate the columns with a character other than a tab:

      paste  -d"!@"  names  places  dates  > npd

    This command alternates "!" and "@" as the column separators.  If the data
    in "names", "places", and "dates" is the same as in Example 1, the file
    "npd" contains:

      rachel!New York@February 5
      jerry!Austin@March 13
      mark!Chicago@June 21
      marsha!Boca Raton@July 16
      scott!Seattle@November 4

  3. To display the standard input in multiple columns:

      ls  |  paste  -  -  -  -

    This command lists the current directory in four columns.  Each - (minus)
    causes the paste command 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,..., 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
    new-line character ("\n") after the fourth.  Without the -d flag, the paste
    -s  -  command would display all of the input as one line with a tab
    between each column.

RELATED INFORMATION

See the following commands:  "grep, egrep, fgrep,"  "cut," and  "pr."

See "Introduction to International Character Support" in Managing the AIX
Operating System.










Processed November 8, 1990        PASTE(1,C)                                  3



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