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的用法完全一致。
注意添加PATH=/usr/local/opt/gnu-sed/libexec/gnubin:/$PATH
	
			
			
			
			
                
微信扫一扫,打赏作者吧~