English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux paste command

Comprehensive Linux Commands

Linux paste command is used to merge columns of files.

The paste command merges each file in a column-by-column manner, merging one column at a time.

Syntax

paste [-s][-d <delimiter character>][--help][--version][File...]

Parameters:

  • -d<delimiter character> or--delimiters=<delimiter character> Replace the tab character with the specified delimiter character.
  • -s or--serial Serial processing instead of parallel processing.
  • --help Online help.
  • --version Show help information.
  • [File…] Specify the file path for the operation

Online example

Use the paste command to merge the files "file", "testfile", "testfile1"to merge, enter the following command:

paste file testfile testfile1 #Merge the content of the specified file 

However, before executing the above commands, first use the "cat" command to3files to be viewed, the display is as follows:

$ cat file                  #The content of the file  
xiongdan 200  
lihaihui 233  
lymlrl 231  
$ cat testfile              #The content of the testfile  
liangyuanm  ss  
$ cat testfile1             #testfile1file content  
huanggai 56  
zhixi 73 

When the merge command1"After execution, the merged file content will be displayed in the program interface as follows:

xiongdan 200  
lihaihui 233  
lymlrl 231  
liangyuanm  ss  
huanggai 56  
zhixi 73  

is used with the paste command's parameters-s"If the option3line data is merged into a single line for display. Enter the following command

$ paste -s file             #Merge the multi-line data of the specified file

The data content displayed after executing the above command is as follows:

xiongdan 200 lihaihui 233 lymlrl 231 

Note: parameter-s"merely adjusts the display mode of the content in the testfile, but will not change the original file content format.

Comprehensive Linux Commands