【问题标题】:sed: -e expression #1, char 5: unterminated `s' command [duplicate]sed:-e 表达式 #1,字符 5:未终止的 `s' 命令 [重复]
【发布时间】:2019-03-17 19:29:00
【问题描述】:

我正在学习 SED,我看到了这个 sed 替换示例。它应该将每个新行中的第一个小写 t 替换为大写。:

$ sed 's/t/T' text-01.txt
  sed: -e expression #1, char 5: unterminated `s' command

文件内容:

 $ cat text-01.txt
   10 tiny toes
   this is that
   5 funny 0
   one two three
   tree twice

这不是世界末日,因为我可以输出到一个新文件中:

cat text-01.txt | sed 's/t/T/' > text-02.txt

但是如果我想编辑原始文件我应该怎么做呢?

【问题讨论】:

    标签: sed


    【解决方案1】:

    命令不一样,第一个中缺少/

    #                           v
                      sed 's/t/T' text-01.txt
    cat text-01.txt | sed 's/t/T/' > text-02.txt
    #                           ^
    

    【讨论】:

    • sigh 感谢您的快速更正
    猜你喜欢
    • 1970-01-01
    • 2021-06-26
    • 2020-11-25
    • 1970-01-01
    • 1970-01-01
    • 2017-07-10
    • 2015-04-27
    • 2014-04-06
    • 2020-11-25
    相关资源
    最近更新 更多