Linux 中的 paste 命令主要用于将多个文件的列进行合并。
该命令会按照列对列的方式,依次把每个文件的内容进行整合输出。
<pre class="brush:php;toolbar:false">paste [-s][-d ][--help][--version][文件...]
常用参数说明:
我们以"file"、"testfile"和"testfile1"三个文件为例,执行以下命令进行内容合并:
<pre class="brush:php;toolbar:false">paste file testfile testfile1 #合并多个文件内容
在运行上述命令之前,先通过"cat"查看各文件的具体内容:
<pre class="brush:php;toolbar:false">$ 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" 后,终端将显示如下合并后的结果:
<pre class="brush:php;toolbar:false">xiongdan 200 lihaihui 233 lymlrl 231 liangyuanm ss huanggai 56 zhixi 73
如果添加"-s"参数,可以实现将一个文件中的多行内容合并为一行展示。例如,对"file"文件执行以下命令:
<pre class="brush:php;toolbar:false">$ paste -s file #将多行内容合并为一行
执行后输出结果如下:
<pre class="brush:php;toolbar:false">xiongdan 200 lihaihui 233 lymlrl 231
注意:使用"-s"参数仅改变输出形式,并不会修改原文件的实际内容格式。
以上就是linux合并文件内容是什么-paste 命令使用与实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号