Merges lines of given input files, and writes the resulting lines to standard output. (POSIX)
paste [-s] [-d list] file
- -d list
- Specifies that each character in the list is an element specifying a delimiter character. 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 special delimiter character, described below. These elements specify one or more delimiters to use, instead of the default tab, to replace the newline of the input lines. If the -s option is also specified:
If the -s option is not specified:
- The last <newline> in a file isn't modified.
- The delimiter is reset to the first element of the list after each file operand is processed.
- The <newline>s in the file specified by the last file operand can't be modified.
- The delimiter is reset to the first element of the list each time a line is processed from each file.
When a backslash character appears in list, the backslash character and the other characters that follow it are used
to represent these delimiter characters:
- \n represents a <newline>
- \t represents a <tab>
- \\ represents a backslash character
- \0 represents an empty string, not a NULL character. If a lower case or upper case “x” immediately follows \0, or any character defined by the LC_CTYPE digit keyword, the results are unspecified. For more information, see the Base Definitions volume of IEEE Std 1003.1-2001, Chapter 7, Locale.
When the escape sequences of the list argument are used in a shell script, you must use single quotation marks; otherwise, the shell interprets the backslash character as a special character.
The input files must be text files.
- Concatenates all lines of each separate input file in command line order. Except for the last line in each input file, the <newline> of every line is replaced with <tab>, unless otherwise specified by the -d option.
- The pathname of an input file. Specifying “-” for one or more of the files uses the standard input, which is input read one line at a time for each instance of “-”.
For every file you name, the paste utility pastes columns
or fields from each line, concatenates them, and writes them to the
By default, paste assumes the field delimiter character to be
tab. You can use the -d option to specify another delimiter.
The following are examples of the list argument:
- Write out a directory in three columns:
ls | paste - - -
- Combine pairs of lines from a file into single lines:
paste -s -d "\t\n" file
- Successful completion.
- An error occurred.