带有 -i 选项(就地编辑)的 sed 命令在 Ubuntu 上运行良好,但在 Mac 上不运行 [英] sed command with -i option (in-place editing) works fine on Ubuntu but not Mac
本文介绍了带有 -i 选项(就地编辑)的 sed 命令在 Ubuntu 上运行良好,但在 Mac 上不运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 Sed 一无所知,但需要此命令(在 Ubuntu 上运行良好)才能在 Mac OSX 上运行:
I know nothing about Sed but need this command (which works fine on Ubuntu) to work on a Mac OSX:
sed -i "/ $domain .*#drupalpro/d" /etc/hosts
我得到:
sed: 1: "/etc/hosts": extra characters at the end of h command
推荐答案
Ubuntu 附带 GNU sed
,其中 -i
选项的后缀是可选的.OS X 附带 BSD sed
,其中后缀是强制性的.试试 sed -i ''
Ubuntu ships with GNU sed
, where the suffix for the -i
option is optional. OS X ships with BSD sed
, where the suffix is mandatory. Try sed -i ''
这篇关于带有 -i 选项(就地编辑)的 sed 命令在 Ubuntu 上运行良好,但在 Mac 上不运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文