PASTE(1POSIX) | POSIX Programmer's Manual | PASTE(1POSIX) |
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.
paste — merge corresponding or subsequent lines of files
paste [-s] [-d list] file...
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.
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:
When the -s option is not specified:
If a <backslash> character appears in list, it and the character following it shall be used to represent the following delimiter characters:
If any other characters follow the <backslash>, the results are unspecified.
The following operand shall be supported:
The standard input shall be used only if one or more file operands is '-'. See the INPUT FILES section.
The input files shall be text files, except that line lengths shall be unlimited.
The following environment variables shall affect the execution of paste:
Default.
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>.
The standard error shall be used only for diagnostic messages.
None.
None.
The following exit values shall be returned:
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.
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().
ls | paste - - - -
paste -s -d "\t\n" file
None.
None.
Section 1.4, Utility Description Defaults, cut, grep, pr
The Base Definitions volume of POSIX.1‐2017, Chapter 7, Locale, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
2017 | IEEE/The Open Group |