Paste (Unix)
Encyclopedia
paste is a Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 command line utility which is used to join files horizontally (parallel merging) by outputting lines consisting of the sequentially corresponding lines of each file specified, separated by tabs, to the standard output. It is effectively the horizontal equivalent to the utility cat
Cat (Unix)
The cat command is a standard Unix program used to concatenate and display files. The name is from catenate, a synonym of concatenate.- Specification :...

 command which operates on the vertical plane of two or more files.

Usage

The paste utility is invoked with the following syntax:

paste [options] [file1 ..]

Description

Once invoked, paste will read all its file arguments. For each corresponding line, paste will append the contents of each file at that line to its output along with a tab. When it has completed its operation for the last file, paste will output a newline character and move on to the next line.

Options

The paste utility accepts the following options:

-d delimiters, which specifies a list of delimiter
Delimiter
A delimiter is a sequence of one or more characters used to specify the boundary between separate, independent regions in plain text or other data streams. An example of a delimiter is the comma character, which acts as a field delimiter in a sequence of comma-separated values.Delimiters represent...

s to be used instead of tabs for separating consecutive values on a single line. Each delimiter is used in turn; when the list has been exhausted, paste begins again at the first delimiter.

-s, which causes paste to append the data in serial rather than in parallel; that is, in a horizontal rather than vertical fashion.

Examples

For the following examples, assume that names.txt is a plain-text file that contains the following information:

Mark Smith
Bobby Brown
Sue Miller
Jenny Igotit


and that numbers.txt is another plain-text file that contains the following information:

555-1234
555-9876
555-6743
867-5309


The following example shows the invocation of paste with names.txt and numbers.txt as well as the resulting output:

$ paste names.txt numbers.txt
Mark Smith 555-1234
Bobby Brown 555-9876
Sue Miller 555-6743
Jenny Igotit 867-5309


When invoked with the -s option, the output of paste is adjusted such that the information is presented in a horizontal fashion:

$ paste -s names.txt numbers.txt
Mark Smith Bobby Brown Sue Miller Jenny Igotit
555-1234 555-9876 555-6734 867-5309


Finally, the use of the -d option (delimiters) is illustrated in the following example:

$ paste -d ., names.txt numbers.txt
Mark Smith.555-1234
Bobby Brown,555-9876
Sue Miller.555-6743
Jenny Igotit,867-5309
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK