# paste

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           paste — merge corresponding or subsequent lines of files
    


## SYNOPSIS



           paste **[** -s**] [** -d _list_**]**_file_...
    


## DESCRIPTION



           The _paste_ utility shall concatenate the corresponding lines of the
           given input files, and write the resulting lines to standard
           output.
    
           The default operation of _paste_ shall concatenate the corresponding
           lines of the input files. The <newline> of every line except the
           line from the last input file shall be replaced with a <tab>.
    
           If an end-of-file condition is detected on one or more input
           files, but not all input files, _paste_ shall behave as though empty
           lines were read from the files on which end-of-file was detected,
           unless the **-s** option is specified.
    


## OPTIONS



           The _paste_ utility shall conform to the Base Definitions volume of
           POSIX.1‐2017, _Section 12.2_ , _Utility Syntax Guidelines_.
    
           The following options shall be supported:
    
           **-d** _list_   Unless a <backslash> character appears in _list_ , each
                     character in _list_ is an element specifying a delimiter
                     character. If a <backslash> character appears in _list_ ,
                     the <backslash> character and one or more characters
                     following it are an element specifying a delimiter
                     character as described below. These elements specify one
                     or more delimiters to use, instead of the default <tab>,
                     to replace the <newline> of the input lines. The
                     elements in _list_ shall be used circularly; that is, when
                     the list is exhausted the first element from the list is
                     reused. When the **-s** option is specified:
    
                      *  The last <newline> in a file shall not be modified.
    
                      *  The delimiter shall be reset to the first element of
                         _list_ after each _file_ operand is processed.
    
                     When the **-s** option is not specified:
    
                      *  The <newline> characters in the file specified by
                         the last _file_ operand shall not be modified.
    
                      *  The delimiter shall be reset to the first element of
                         list each time a line is processed from each file.
    
                     If a <backslash> character appears in _list_ , it and the
                     character following it shall be used to represent the
                     following delimiter characters:
    
                     \n    <newline>.
    
                     \t    <tab>.
    
                     \\    <backslash> character.
    
                     \0    Empty string (not a null character). If **'\0'** is
                           immediately followed by the character **'x'** , the
                           character **'X'** , or any character defined by the
                           _LC_CTYPE_ **digit** keyword (see the Base Definitions
                           volume of POSIX.1‐2017, _Chapter 7_ , _Locale_), the
                           results are unspecified.
    
                     If any other characters follow the <backslash>, the
                     results are unspecified.
    
           **-s** Concatenate all of the lines from each input file into
                     one line of output per file, in command line order. The
                     <newline> of every line except the last line in each
                     input file shall be replaced with a <tab>, unless
                     otherwise specified by the **-d** option. If an input file
                     is empty, the output line corresponding to that file
                     shall consist of only a <newline> character.
    


## OPERANDS



           The following operand shall be supported:
    
           _file_      A pathname of an input file. If **'-'** is specified for one
                     or more of the _file_ s, the standard input shall be used;
                     the standard input shall be read one line at a time,
                     circularly, for each instance of **'-'**.  Implementations
                     shall support pasting of at least 12 _file_ operands.
    


## STDIN



           The standard input shall be used only if one or more _file_ operands
           is **'-'**.  See the INPUT FILES section.
    


## INPUT FILES



           The input files shall be text files, except that line lengths
           shall be unlimited.
    


## ENVIRONMENT VARIABLES



           The following environment variables shall affect the execution of
           _paste_ :
    
           _LANG_      Provide a default value for the internationalization
                     variables that are unset or null. (See the Base
                     Definitions volume of POSIX.1‐2017, _Section 8.2_ ,
                     _Internationalization Variables_ the precedence of
                     internationalization variables used to determine the
                     values of locale categories.)
    
           _LC_ALL_    If set to a non-empty string value, override the values
                     of all the other internationalization variables.
    
           _LC_CTYPE_  Determine the locale for the interpretation of sequences
                     of bytes of text data as characters (for example,
                     single-byte as opposed to multi-byte characters in
                     arguments and input files).
    
           _LC_MESSAGES_
                     Determine the locale that should be used to affect the
                     format and contents of diagnostic messages written to
                     standard error.
    
           _NLSPATH_   Determine the location of message catalogs for the
                     processing of _LC_MESSAGES_.
    


## ASYNCHRONOUS EVENTS



           Default.
    


## STDOUT



           Concatenated lines of input files shall be separated by the <tab>
           (or other characters under the control of the **-d** option) and
           terminated by a <newline>.
    


## STDERR



           The standard error shall be used only for diagnostic messages.
    


## OUTPUT FILES



           None.
    


## EXTENDED DESCRIPTION



           None.
    


## EXIT STATUS



           The following exit values shall be returned:
    
            0    Successful completion.
    
           >0    An error occurred.
    


## CONSEQUENCES OF ERRORS



           If one or more input files cannot be opened when the **-s** option is
           not specified, a diagnostic message shall be written to standard
           error, but no output is written to standard output. If the **-s**
           option is specified, the _paste_ utility shall provide the default
           behavior described in _Section 1.4_ , _Utility Description Defaults_.
    
           _The following sections are informative._
    


## APPLICATION USAGE



           When the escape sequences of the _list_ option-argument are used in
           a shell script, they must be quoted; otherwise, the shell treats
           the <backslash> as a special character.
    
           Conforming applications should only use the specific
           <backslash>-escaped delimiters presented in this volume of
           POSIX.1‐2017. Historical implementations treat **'\x'** , where **'x'** is
           not in this list, as **'x'** , but future implementations are free to
           expand this list to recognize other common escapes similar to
           those accepted by _printf_ and other standard utilities.
    
           Most of the standard utilities work on text files. The _cut_ utility
           can be used to turn files with arbitrary line lengths into a set
           of text files containing the same data. The _paste_ utility can be
           used to create (or recreate) files with arbitrary line lengths.
           For example, if _file_ contains long lines:
    
               cut -b 1-500 -n file > file1
               cut -b 501- -n file > file2
    
           creates **file1**(a text file) with lines no longer than 500 bytes
           (plus the <newline>) and **file2** that contains the remainder of the
           data from _file_.  Note that **file2** is not a text file if there are
           lines in _file_ that are longer than 500 + {LINE_MAX} bytes. The
           original file can be recreated from **file1** and **file2** using the
           command:
    
               paste -d "\0" file1 file2 > file
    
           The commands:
    
               paste -d "\0" ...
               paste -d "" ...
    
           are not necessarily equivalent; the latter is not specified by
           this volume of POSIX.1‐2017 and may result in an error. The
           construct **'\0'** is used to mean ``no separator'' because historical
           versions of _paste_ did not follow the syntax guidelines, and the
           command:
    
               paste -d"" ...
    
           could not be handled properly by _getopt_().
    


## EXAMPLES



            1. Write out a directory in four columns:
    
                   ls | paste - - - -
    
            2. Combine pairs of lines from a file into single lines:
    
                   paste -s -d "\t\n" file
    


## RATIONALE



           None.
    


## FUTURE DIRECTIONS



           None.
    


* * *