Beginner’s guide to Linux commands – paste

Today we are going to look at paste command in Linux. Paste man page says it’s a tool to “merge lines of files”, that is correct it merges each line in one or more than one files.

Take a Look at file named file.txt

Without any option paste command works like cat.

Merging Lines in to one using paste

With -s option paste merges all the lines in the file in to one with tab as separator.

Replacing default delimiter in paste

We can replace default tab delimiter with -d option.

This is a useful option. For example, if you want to add all numbers in a file. Then try:

Merging Lines in to different column with and without delimiter in paste

paste can merge lines in to different columns instead of single line.

Pasting contents of 2 files side by side

Read lines in both the files alternatively

Thats all about paste. Hope it will add more knowledge in to your command line skills.