我的npm脚本需要运行sed来替换某些字符串,例如
"prebuild":"sed 's/http:\/\/example.com/https:\/\/something_real.com/' < static/config.js.example > static/config.js",
"build": "node build/build.js"
但是运行npm run build
时,shell会解释反溅转义,所以我得到了错误,
qiulang$ npm run build
> sed 's/http://example.com/https://something_real/' < static/config.js.example > static/config.js
sed: 1: "s/http://emicall-cmb.em ...": bad flag in substitute command: 'e'
那我如何防止shell这么做呢?
答案 0 :(得分:1)
您可以使用其他字符作为分隔符
sed 's@http://example.com@https://something_real.com@' < static/config.js.example > static/config.js