上简单的替换操作

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的用法完全一致。




相关文章:

  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-08-13
  • 2022-12-23
  • 2021-10-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案