【问题标题】:how to move change the cat output into columns [duplicate]如何将cat输出更改为列[重复]
【发布时间】:2015-08-18 18:01:25
【问题描述】:

所以这是我在 cat 多个配置文件和 grep 文件名和修改日期时的输出。

/path-to-file/name of file
modified date
/path-to-file/name of file
modified date
/path-to-file/name of file
modified date

我希望输出是这样的,如果可能的话,在单词“文件”之后添加逗号。

/path-to-file/name of file, modified date
/path-to-file/name of file, modified date
/path-to-file/name of file, modified date
/path-to-file/name of file, modified date

【问题讨论】:

  • 通过写shell脚本,读两行写一行。

标签: linux ubuntu grep cat


【解决方案1】:

将您的输出输入到paste -d, - -,它将连接输入中的每一对行。

【讨论】:

    【解决方案2】:

    将您的输出通过管道传输到awk '{printf "%s%s",$0,NR%2?", ":"\n"}'

    【讨论】:

    • 谢谢完美...没有逗号我该怎么做?因为我得到两个逗号...一个在顶部和底部。 log.7',
    • @fer 去掉 awk one-liner 中的逗号。
    猜你喜欢
    • 2019-11-16
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 2020-01-21
    • 2013-08-23
    • 2015-09-29
    相关资源
    最近更新 更多