sed - sed:-e 表达式 #1,字符 5:未终止的 `s' 命令
问题描述
我正在学习 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
但是,如果我想编辑原始文件,我应该怎么做?
解决方案
命令不一样,/
第一个命令中缺少关闭:
# v
sed 's/t/T' text-01.txt
cat text-01.txt | sed 's/t/T/' > text-02.txt
# ^
推荐阅读
- python - 如何从 Django 中的 F() / F() 获取浮点数
- python - 如何在 Wagtail 中添加片段描述
- python - Python:处理多个独立异常
- typescript - 在对象打字稿上添加/重命名键
- bash - 如何在 scp 命令中使用文件名中的白色空白
- python - 如何将相同的过程应用于熊猫中的多个csv文件并将其保存在另一个目录中?
- java - 是否有模式注册表规范?
- azure-devops - 为什么天蓝色构建管道不为角度构建生成 dist 文件夹
- javascript - 将 JavaScript 导入 React
- python-3.x - 从 Txt 文件 Python 运行 SQL 查询