从spawn调用'sed'时出错

时间:2016-03-25 09:27:51

标签: unix sed send spawn

我正在尝试从spawn中执行send "sed -e\'s/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g\' test_log" ,但它给我带来了这个错误:

bash-4.1$ invalid command name "0-9A-F"
while executing
"0-9A-F"
invoked from within
"send "sed -e\'s/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g\' test_log""
(file "./test.sh" line 19)

我已经为\中的转义字符添加了sed,但它仍无效。

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

不要逃避sed中的单引号 即使用

sed -e\'s/%\([0-9A-F][0-9A-F]\)/\\\\\x\1/g\' test_log

而不是

{{1}}