Linux paste command with examples

In this article, we will see Linux paste command with examples. Linux Paste command is used to join files horizontally by outputting lines consisting of lines from each file specified, separated by tab as delimiter, to the standard output.

Syntax:

paste OPTION... [FILE]...

We are going to perform examples on the following files names.txt and emp.txt.

Linux paste command with examples

Linux paste command examples:

1. Simply combine the file content from names.txt and emp.txt file

paste names.txt emp.txt

2. Combine files with delimiter with pipe symbol or _

paste -d "|" names.txt emp.txt

3. Merge files sequentiallly.

We can merge the files in sequentially using the -s option. The paste command reads each file in sequentially. It reads all the lines from a single file and merges all these lines into a single line.

paste -s names.txt emp.txt

4. Save merged files output to a file using Linux paste command.

paste names.txt emp.txt > empnames.txt

5. We can also use Linux paste command to view the contents of a file.

paste names.txt

So, Linux paste command is used to merge lines of multiple files.