linux - sed: sed: -e 表达式 #1, char 63: 未终止的 `s' 命令

标签 linux bash unix ubuntu sed

我正在尝试使用 sed 替换文本但遇到以下错误:

[root@server3 ~]# echo "{"playlist":[" | sed 's#{"playlist":[#{"playlist":[{"comment":" text 1","playlist":[#'
sed: -e expression #1, char 63: unterminated `s' command

最佳答案

您需要对模式中的 [ 进行转义,这样 sed 就不会认为您正在尝试启动字符列表。

echo "test" | sed 's#{"playlist":\[#{"playlist":[{"comment":" text 1","playlist":[#'

关于linux - sed: sed: -e 表达式 #1, char 63: 未终止的 `s' 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10706630/

相关文章:

bash - 替换不在括号中的数字?

linux - 在特定目录的特定文件中使用 find 和 grep

linux - 需要将以下 awk 命令转换为 sed

linux - Bash 字符串日期错误值

Linux 下 Eclipse 中 Java 体积没有变化

bash - 在包装 bash 脚本中设置管道

macos - 从 OSX Automator shell 脚本运行 Grunt

c - sigqueue() 向进程组发送信号

linux - 如何从文本文件中获取文件路径并在 bash 中执行操作

linux - Ubuntu 16.10 在运行时随机化函数地址