一条很简单的替换文本的命令:服务器
sed -i 's/www.a.cn/www.b.com/g' common.js,报错command c expects \ followed by textspa
可是一样的命令在服务器上是能够正确执行的,看了mac下的man sed,里面-i选项中的解释:ci
Edit files in-place, saving backups with the specified extension.it
If a zero-length extension is given, no backup will be saved. Itio
is not recommended to give a zero-length extension when in-placeclass
editing files, as you risk corruption or partial content in situ-sed
ations where disk space is exhausted, etc.file
大概的意思就是说用-i的选项时mac会进行强制备份,因此你必须给出一个后缀名进行备份,若是你不想进行备份,直接用空字符便可command
sed -i '' 's/www.a.cn/www.b.com/g' common.jsdi