我在 Linux 中有一个名为 1.txt 的多行文件,需要每三行合并
进入一行。我已经提到了下面的输出,并且需要知道如何做到这一点
[xxx@c0040229 ~]$ cat 1.txt
c0043726.xxx.xx
50G,3.6G,44G,8%,/opt/tibco
200K,/opt/tibco/scripts
c0043725.xxx.xx
50G,9.5G,38G,21%,/opt/tibco
196K,/opt/tibco/scripts
c0043724.xxx.xx
50G,1.6G,46G,4%,/opt/tibco
92K,/opt/tibco/scripts
输出应该是
c0043726.xxx.xx,50G,3.6G,44G,8%,/opt/tibco,200K,/opt/tibco/scripts
c0043725.xxx.xx,50G,9.5G,38G,21%,/opt/tibco,196K,/opt/tibco/scripts
c0043724.xxx.xx,50G,1.6G,46G,4%,/opt/tibco,92K,/opt/tibco/scripts
有人可以帮我吗?
最佳答案
我认为你可以使用粘贴命令实现你想要的:
cat 1.txt | paste -d',' - - -
关于linux - 在linux shell脚本中将多行添加到一行中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25074308/