【发布时间】:2015-11-07 12:54:43
【问题描述】:
我正在尝试在特定行之前插入几行文本,但是当我尝试添加新行字符时不断收到 sed 错误。我的命令如下所示:
sed -r -i '/Line to insert after/ i Line one to insert \\
second new line to insert \\
third new line to insert' /etc/directory/somefile.txt
报错是:
sed: -e expression #1, char 77: unterminated `s' command
我试过了,使用\n,\\(如示例),根本没有字符,只是将第二行移到下一行。我也尝试过类似的方法:
sed -r -i -e '/Line to insert after/ i Line one to insert'
-e 'second new line to insert'
-e 'third new line to insert' /etc/directory/somefile.txt
编辑!:抱歉,我希望在现有文本之前插入文本,而不是之后!
【问题讨论】:
标签: bash unix sed text-manipulation