【问题标题】:How to replace square brackets with a space using tr?如何使用tr用空格替换方括号?
【发布时间】:2017-09-28 04:55:57
【问题描述】:

使用“tr -c”命令。我基本上需要用空格('')替换方括号([,])并且只使用sed来解决问题。可以翻译吗?

【问题讨论】:

  • 请在代码标签中发布示例 Input_file。

标签: bash tr


【解决方案1】:

只是:

tr '[]' ' ' < file

-c 选项在这种情况下没有帮助。

【讨论】:

    【解决方案2】:

    如果你只是想替换方括号,你可以使用这样的东西:

     $: tr '[]' ' ' < inputfile
    

    这将返回带有空格而不是括号的输入文件。如果常规 tr 就足够了,不知道为什么要使用 tr -c

    此处有用链接:http://www.thegeekstuff.com/2012/12/linux-tr-command/

    【讨论】:

    • 这不会用空格替换方括号。
    • 对不起,我昨晚没戴眼镜。我会修改它。
    猜你喜欢
    • 1970-01-01
    • 2014-11-07
    • 2019-12-03
    • 2011-05-04
    • 2017-07-05
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    相关资源
    最近更新 更多