Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ paste(1) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

grep

cut

pr

paste

PURPOSE

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

SYNOPSIS
     paste file1 file2 ...
     paste -dlist file1 file2 ...
     paste -s [ -dlist ] file1 ...


DESCRIPTION

     The paste  command reads  input files (standard  input if
     you specify a - as  a file name), concatenates the corre-
     sponding lines of  the given input files,  and writes the
     resulting  lines to  standard output.   Output lines  are
     restricted to 511 characters.

     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).  You  can think
     of paste as the counterpart  of the cat command (see page
     129), which  concatenates files vertically, that  is, one
     file after another.

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

     Note:   The action  of pr  -t -m  is similar  to that  of
     paste, but  creates extra  blanks, tabs  and lines  for a
     nice page layout.

FLAGS

     -dlist  Changes  the  delimiter   that  separates  corre-
             sponding  lines in  the output  with one  or more
             characters in  list (the  default is a  tab).  If
             more than one character is in list, then they are
             repeated in  order until  the end of  the output.
             In parallel merging, the lines from the last file
             always end with a  new-line character, instead of
             one 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 hor-
             izontally.  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 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 paste several columns of data together:

           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.  If "names",  "places", and
         "dates" look like:

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

         then "npd" contains:

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

         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 alternates "!" and "@" as the column separators.
         If "names", "places", and "dates"  are the same as in
         Example 1, then "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  lists the  current directory  in four  columns.
         Each - 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, . .  . , 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 subse-
         quent   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, paste -s  - would
         display  all of  the input  as  one line  with a  tab
         between each column.

RELATED INFORMATION

     The following commands:  "grep,"  "cut," and "pr."

     The "Overview of International Character Support" in Man-
     aging the AIX Operating System.

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