上簡單的替換操作
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的用法完全一致。
