使用sed命令替换文本内容的时候出现报错,如下

 1 sed -i 's/HostName/#HostName/g' /Users/gwd/.ssh/config 

sed: 1: "/Users/gwd/.ssh/config": extra characters at the end of g command

报错“sed: 1: "/Users/gwd/.ssh/config": extra characters at the end of g command”,原因在于在OS X需要显式指定扩展名,解决方案是设置一个空字符串,即执行以下命令即可

 1 sed -i '' 's/HostName/#HostName/g' /Users/gwd/.ssh/config 

相关文章:

  • 2021-05-04
  • 2021-10-24
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2021-11-14
  • 2022-12-23
猜你喜欢
  • 2021-06-29
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2021-07-15
相关资源
相似解决方案