bash Sed 错误“命令 a 需要 \ 后跟文本”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37356444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 14:39:22 来源:igfitidea点击:
Sed error "command a expects \ followed by text"
提问by
Here is my script:
这是我的脚本:
openscad -D generate=1 -o .csg 2>&1 >/dev/null |
sed 's/ECHO: \"\[LC\] //' |
sed 's/"$//' |
sed '$a;' >./2d_
That output:
那个输出:
sed: 1: "$a;": command a expects \ followed by text
采纳答案by Jonathan Leffler
Your version of sed
is not GNU sed
which allows what you use. You need to write:
您的版本sed
不是 GNU sed
,它允许您使用什么。你需要写:
openscad -D generate=1 -o .csg 2>&1 >/dev/null |
sed 's/ECHO: \"\[LC\] //' |
sed 's/"$//' |
sed '$a\
;' >./2d_
Also, three copies of sed
is a little excessive (to be polite); one suffices:
另外,三份sed
有点过分(礼貌);一个就够了:
openscad -D generate=1 -o .csg 2>&1 >/dev/null |
sed -e 's/ECHO: \"\[LC\] //' \
-e 's/"$//' \
-e '$a\' \
-e ';' >./2d_
or:
或者:
openscad -D generate=1 -o .csg 2>&1 >/dev/null |
sed -e 's/ECHO: \"\[LC\] //' -e 's/"$//' -e '$a\' -e ';' >./2d_