在配置文件中,我试图替换PREFIX=/jenkins
为PREFIX=/foobar
.
在(bash)命令行上,这工作正常:
sed -i.bak s/PREFIX=\\/jenkins/PREFIX=\\/foobar/g /etc/default/jenkins
但是,在 Puppet 脚本(.pp 文件)中:
exec { 'Change-prefix':
command => "sed -i.bak s/PREFIX=\\/jenkins/PREFIX=\\/foobar/g /etc/default/jenkins",
path => ["/bin"],
}
产生:
err: /Stage[main]//Exec[Change-prefix]/returns: change from notrun to 0 failed:
sed -i.bak s/PREFIX=\/jenkins/PREFIX=\/foobar/g /etc/default/jenkins
returned 1 instead of one of [0]
如何正确转义 sed 命令?还是有其他问题?
我也尝试过\\\/
,但结果是:warning: Unrecognised escape sequence '\/'