gpt4 book ai didi

linux - 在shell脚本linux中将多行添加到一行

转载 作者:太空狗 更新时间:2023-10-29 11:44:36 25 4
gpt4 key购买 nike

我在 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 - 在shell脚本linux中将多行添加到一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25074308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com