我尝试在 OSX 上安装 GNU grep,它似乎已安装,但我无法使用它。我已经使用自制程序完成了此操作,Macports 目前遇到了一些问题,所以我无法使用它。
安装:brew tap homebrew/dupes; brew install grep
返回:Warning: homebrew/dupes already tapped! Warning: homebrew/dupes/grep-2.21 already installed
符号链接似乎适用于 /usr/local/bin/ggrep。当我添加别名时alias grep="ggrep"
and do grep --version
, I get -bash: ggrep: command not found
。这是真的,因为文件夹中没有 ggrep。我尝试过安装和不安装--with-default-names
.
文件夹/usr/local/Cellar/grep/2.21/bin/
包含以下内容:
-r-xr-xr-x 1 Wes admin 158 Oct 14 09:27 egrep
-r-xr-xr-x 1 Wes admin 158 Oct 14 09:27 fgrep
这对我来说很奇怪,因为文档暗示The command has been installed with the prefix "g".
我看过以下帖子,但没有一个解决方案对我有用。更新 Mac OS 10.7 的 grep https://stackoverflow.com/questions/8352197/updating-grep-for-mac-os-10-7/26064330#26064330
有人有解决办法吗?我真的很想使用 GNU grep。
输出brew unlink grep && brew link grep -v
:
Unlinking /usr/local/Cellar/grep/2.21...
6 symlinks removed
Linking /usr/local/Cellar/grep/2.21...
ln -s ../Cellar/grep/2.21/bin/egrep egrep
ln -s ../Cellar/grep/2.21/bin/fgrep fgrep
ln -s ../../Cellar/grep/2.21/share/info/grep.info grep.info info /usr/local/share/info/grep.info
ln -s ../../../Cellar/grep/2.21/share/man/man1/egrep.1 egrep.1
ln -s ../../../Cellar/grep/2.21/share/man/man1/fgrep.1 fgrep.1
ln -s ../../../Cellar/grep/2.21/share/man/man1/grep.1 grep.1
6 symlinks created`
New:
brew uninstall grep; brew install grep
$ which -a grep
/usr/bin/grep
$ which -a ggrep
/usr/local/bin/ggrep
$ echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin
这一次,似乎有些不一样了。ggrep
终于安装好了!我觉得unlink
/link
理清了一些事情。
我该如何设置ggrep
作为默认值?和alias
?