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

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

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

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 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄