mac
上简单的替换操作
sed -i 's/apple/mac/g' full-path-file
执行后报错,“sed: 1: command a expects \ followed by text”
由于mac
系统与linux
系统下sed
用法的差异,下面给出两种解决方案
(差异可自己在两个系统用man命令查看帮助)
第一种解决方案
将sed
命令改写为
sed -i '' 's/apple/mac/g' full-path-file
第二种解决方案
调整mac
下sed
的用法,使其与linux
一致
mac
上安装gnu-sed
brew install gnu-sed
alias sed=gsed
调整后两系统下sed
的用法完全一致。