Answers:
您需要安装gnu-sed,而不仅仅是coreutils:
brew install gnu-sed
然后,您必须在上添加以下行.bash_profile:
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
export MANPATH="/usr/local/opt/gnu-sed/libexec/gnuman:$MANPATH"
然后您的sed版本应该是最新的:
$ sed --version
sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
PATH陈述。Just brew install gnu-sed,它将以gsed
PATH语句使您可以使用命令sed而不是gsed。没必要,但是您无需记住将字母附加g到sed命令中。
sedBSD sed的程序。我不知道这是否有问题,但我希望它会成为问题。(如果是osx,然后是bsdisms)
alias sed=gsed在个人资料中,也许吗?
-E选件的普通OS X sed ,则应接受\t。有关re_format详细信息,请参见手册页。