Paste (Unix)

pasteOperating system| Unix and Unix-like

|

Platform| Cross-platform
Type| Command
License| coreutils: GPLv3+

paste is a Unix 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.

## History

[edit]

The original Bell Labs version was written by Gottfried W. R. Luderer.[1][2] The version of `paste` bundled in GNU coreutils was written by David M. Ihnat and David MacKenzie.[3] The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[4]

## Usage

[edit]

The paste utility is invoked with the following syntax:

paste [options] [file1 ..]

## Description

[edit]

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.

paste exits after all streams return end of file. The number of lines in the output stream will equal the number of lines in the input file with the largest number of lines. Missing values are represented by empty strings.

Though potentially useful, an option to have paste emit an alternate string for a missing field (such as "NA") is not standard.

A sequence of empty records at the bottom of a column of the output stream may or may not have been present in the input file corresponding to that column as explicit empty records, unless you know the input file supplied all rows explicitly (e.g. in the canonical case where all input files all do indeed have the same number of lines).

## Options

[edit]

The paste utility accepts the following options:

`-d|--delimiters delimiters`, which specifies a list of delimiters 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|--serial`, which causes paste to append the data in serial rather than in parallel; that is, in a horizontal rather than vertical fashion.

## Examples

[edit]

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 `--serial` option (`-s` on BSD or older systems), the output of paste is adjusted such that the information is presented in a horizontal fashion:

$ paste --serial 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 `--delimiters` option (`-d` on BSD or older systems) is illustrated in the following example:

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

As an example usage of both, the paste command can be used to concatenate multiple consecutive lines into a single row:

$ paste --serial --delimiters '\t\n' names.txt
Mark Smith       Bobby Brown
Sue Miller       Jenny Igotit

## See also

[edit]

* join
* cut
* List of Unix commands
* lam(1), formatted paste with width and justification; not core Unix

## References

[edit]

1. ^ "paste(1) - OpenBSD manual pages".
2. ^ "[TUHS] A portrait of cut(1)".
3. ^ "Paste(1): Merge lines of files - Linux man page".
4. ^ "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.

## External links

[edit]

The Wikibook Guide to Unix has a page on the topic of: Commands

* "PASTE(1) - FreeBSD General Commands Manual". Retrieved 2010-08-12.

* v
* t
* e

Unix command-line interface programs and shell builtins

File system|

* cat
* chattr
* chmod
* chown
* chgrp
* cksum
* cmp
* cp
* dd
* du
* df
* file
* fuser
* ln
* ls
* mkdir
* mv
* pax
* pwd
* rm
* rmdir
* split
* tee
* touch
* type
* umask

Processes|

* at
* bg
* crontab
* fg
* kill
* nice
* ps
* time

User environment|

* env
* exit
* logname
* mesg
* talk
* tput
* uname
* who
* write

Text processing|

* awk
* basename
* comm
* csplit
* cut
* diff
* dirname
* ed
* ex
* fold
* head
* iconv
* join
* m4
* more
* nl
* paste
* patch
* printf
* read
* sed
* sort
* strings
* tail
* tr
* troff
* uniq
* vi
* wc
* xargs

Shell builtins|

* alias
* cd
* echo
* test
* unset
* wait

Searching|

* find
* grep

Documentation|

* man

Software development|

* ar
* ctags
* lex
* make
* nm
* strip
* yacc

Miscellaneous|

* bc
* cal
* expr
* lp
* od
* sleep
* true and false

* Categories
* Standard Unix programs
* Unix SUS2008 utilities
* List

* v
* t
* e

GNU Core Utilities command-line interface programs

File system|

* chcon
* chmod
* chown
* chgrp
* cksum
* cp
* dd
* df
* dir
* dircolors
* install
* ln
* ls
* mkdir
* mkfifo
* mknod
* mktemp
* mv
* realpath
* rm
* rmdir
* shred
* sync
* touch
* truncate
* vdir

Text utilities|

* b2sum
* base32
* base64
* cat
* cksum
* comm
* csplit
* cut
* expand
* fmt
* fold
* head
* join
* md5sum
* nl
* numfmt
* od
* paste
* ptx
* pr
* sha1sum
* shuf
* sort
* split
* sum
* tac
* tail
* tr
* tsort
* unexpand
* uniq
* wc

Shell utilities|

* arch
* basename
* chroot
* date
* dirname
* du
* echo
* env
* expr
* factor
* false
* groups
* hostid
* id
* link
* logname
* nice
* nohup
* nproc
* pathchk
* pinky
* printenv
* printf
* pwd
* readlink
* runcon
* seq
* sleep
* stat
* stdbuf
* stty
* tee
* test
* timeout
* true
* tty
* uname
* unlink
* uptime
* users
* who
* whoami
* yes

*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template