Linux paste command
The Linux paste command is used to merge columns of files.
The paste command merges each file column by column.
Syntax
paste [-s][-d <间隔字符>][--help][--version][文件...]
Parameters:
- -d<delimiter> or --delimiters=<delimiter> Use the specified delimiter character instead of the tab character.
- -s or --serial Process serially rather than in parallel.
- --help Online help.
- --version Display help information.
- [file...] Specify the file path(s) to operate on.
Examples
Use the paste command to merge the files "file", "testfile", and "testfile1". Enter the following command:
paste file testfile testfile1 #合并指定文件的内容
However, before executing the above command, first use the "cat" command to view the contents of the three files, as shown below:
$ cat file #file文件的内容 xiongdan 200 lihaihui 233 lymlrl 231 $ cat testfile #testfile文件的内容 liangyuanm ss $ cat testfile1 #testfile1文件的内容 huanggai 56 zhixi 73
After executing the merge command "$ paste file testfile testfile1", the program interface will display the merged file contents as shown below:
xiongdan 200 lihaihui 233 lymlrl 231 liangyuanm ss huanggai 56 zhixi 73
If you use the "-s" parameter of the paste command, you can merge multiple lines of data in a file into one line for display. For example, to merge the 3 lines of data in file "file" into one line for display, enter the following command:
$ paste -s file #合并指定文件的多行数据
After the above command is executed, the displayed data content is as follows:
xiongdan 200 lihaihui 233 lymlrl 231
Note: The "-s" parameter only adjusts the display mode of the testfile file contents and does not change the format of the original file.
Other Extensions
Linux Command Collection