Linux paste Command
The Linux paste command is used to merge columns of files.
The paste command merges each file column by column, combining them one column at a time.
Syntax
paste [-s][-d <delimiter>][--help][--version][file...]
Parameters:
-d<delimiter> or --delimiters=<delimiter> Use the specified delimiter instead of tab characters.
-s or --serial Process sequentially rather than in parallel.
--help Display online help.
--version Show version information.
[file...] Specify the file paths to operate on.
Example
Use the paste command to merge the files "file", "testfile", and "testfile1", with the following command:
paste file testfile testfile1 # Merge the contents of specified files
However, before executing the above command, first view the contents of the three files using the "cat" command, as shown below:
$ cat file # Contents of file
xiongdan 200
lihaihui 233
lymlrl 231
$ cat testfile # Contents of testfile
liangyuanm ss
$ cat testfile1 # Contents of testfile1
huanggai 56
zhixi 73
After the merge command "$ paste file testfile testfile1" is executed, the merged file contents will be displayed as follows:
xiongdan 200
lihaihui 233
lymlrl 231
liangyuanm ss
huanggai 56
zhixi 73
If the parameter "-s" is used with the paste command, it can combine multiple lines of data from a file into a single line for display. For example, to combine three lines of data from the "file" into a single line for display, enter the following command:
$ paste -s file # Combine multiple lines of data from the specified file
The above command will display the data as follows:
xiongdan 200 lihaihui 233 lymlrl 231
Note: The parameter "-s" only adjusts the display format of the testfile content and does not change the original file's content format.