Paste command in Linux with examples
Paste command is one of the useful commands in Unix or Linux operating system. It is used to join files horizontally (parallel merging) by outputting lines consisting of lines from each file specified, separated by tab as delimiter, to the standard output. When no file is specified, or put dash (“-“) instead of file name, paste reads from standard input and gives output as it is until a interrupt command [Ctrl-c] is given.
paste [OPTION]... [FILES]...
Let us consider three files having name state, capital and number. state and capital file contains 5 names of the Indian states and capitals respectively. number file contains 5 numbers.
$ cat state Arunachal Pradesh Assam Andhra Pradesh Bihar Chhattisgrah $ cat capital Itanagar Dispur Hyderabad Patna Raipur
Without any option paste merges the files in parallel. The paste command writes corresponding lines from the files with tab as a deliminator on the terminal.
$ paste number state capital 1 Arunachal Pradesh Itanagar 2 Assam Dispur 3 Andhra Pradesh Hyderabad 4 Bihar Patna 5 Chhattisgrah Raipur
In the above command three files are merges by paste command.