Linux paste command: merge lines of files
Linux paste command Function Description
Use the paste command to write each line from each specified file to the standard output on the corresponding line, separated by tabs.
If no file is specified, or if the specified file is -
, the program will read the data from the standard input.
Linux paste command Syntax
paste [option] [file]
The meaning of each option in the command is shown in the table.
Option | Description |
---|---|
-d <List> |
Replace the tab separator with a character from the specified list |
-s | Instead of using parallel line output mode, each file occupies one line |
Linux paste command Example
Merge the lines of the /root/ab and /root/ac files.
[root@rhel ~]# cat /root/ab
a
abc
[root@rhel ~]# cat /root/ac
a
abcd
[root@rhel ~]# paste /root/ab /root/ac
a a
abc abcd
Merge the lines of the apidemos.com.sort.txt and apidemos.com.txt files and use the @ character instead of the tab separator.
paste -d @ apidemos.com.sort.txt apidemos.com.txt
Output: