English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Linux paste command for merging columns of files.
The paste command merges each file column by column, one column at a time.
paste [-s][-d <delimiter character>][--help][--version][file...]
Parameter:
Use the paste command to merge the files "file", "testfile", and "testfile1", and enter the following command:
test file testfile testfile1 #merge the contents of specified files
但是,在执行以上命令之前,首先使用"cat"指令对3个文件内容进行查看,显示如下所示:
$ cat file #file文件的内容 xiongdan 200 lihaihui 233 lymlrl 231 $ cat testfile #testfile文件的内容 liangyuanm ss $ cat testfile1 #testfile1文件的内容 huanggai 56 zhixi 73
当执行合并指令"$ paste file testfile testfile1"后,程序界面中将显示合并后的文件内容,如下所示:
xiongdan 200 lihaihui 233 lymlrl 231 liangyuanm ss huanggai 56 zhixi 73
若使用paste指令的参数"-s",则可以将一个文件中的多行数据合并为一行进行显示。例如,将文件"file"中的3行数据合并为一行数据进行显示,输入如下命令
$ paste -s file #合并指定文件的多行数据
执行命令上述后,显示的数据内容如下所示:
xiongdan 200 lihaihui 233 lymlrl 231
注意:参数"-s"仅将testfile文件的内容调整显示方式,并不会改变原文件的内容格式。