paste: Join multiple files into one
paste command can be used to join multiple files and display on the standard output or redirect it to a new file.
For e.g. let us take the following two example files
1 2 3 4
one two three four
These two files can be joined as follows
$ paste file1 file2 1 one 2 two 3 three 4 four
The files are joined line by line and the default delimiter between the lines is a TAB space. This can be changed using the option “-d”.
$ paste -d “:” file1 file2 1:one 2:two 3:three 4:four
The output can be sent to anothe file using output redirection.
$ paste -d “:” file1 file2 > pst $ cat pst 1:one 2:two 3:three 4:four
Instead of joining the files line by line it can be made to join seuentially i.e. one file after another using the option “-s”
$ paste -s file1 file2 1 2 3 4 one two three four
The number of input files can be more than too also, the same rules apply to all of them .