sed:替代模式中未转义的换行符?
sed: unescaped newline inside substitute pattern?
此代码:
echo Foo | sed -e 's/Foo/Bar'
结果 unescaped newline inside substitute pattern
(而不是预期的 Bar
)。
我显然忽略了一些简单的事情,bash/sed/escaping 相关,但我无法找出是什么原因造成的?
您缺少终止符 /
:
echo Foo | sed -e 's/Foo/Bar/'
此代码:
echo Foo | sed -e 's/Foo/Bar'
结果 unescaped newline inside substitute pattern
(而不是预期的 Bar
)。
我显然忽略了一些简单的事情,bash/sed/escaping 相关,但我无法找出是什么原因造成的?
您缺少终止符 /
:
echo Foo | sed -e 's/Foo/Bar/'