我已經嘗試在OSX上安裝GNU grep,並且它似乎已經安裝,但是我無法使用它..我已經使用自制軟件,Macports目前有一些問題,所以我不能使用它。在OSX上安裝了GNU grep,但不能使用
要安裝: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"
和做grep --version
,我得到-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".
我已經看到了下面的帖子,但沒有一個解決方案,爲我工作。 Updating grep for Mac OS 10.7
有沒有人有任何解決方案?我真的想使用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`
新: 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
?
'brew unlink grep && brew link grep -v'的輸出是什麼? – cel
您是否知道'$ PATH'環境變量? – trojanfoe
你可以做些什麼來使我們更容易幫助你:1)安裝grep,沒有默認名字2)添加'which -a grep'和'which -a ggrep'的輸出。 3)添加'echo $ PATH'的輸出。此外,最好編輯一個問題以添加更多信息。評論中的其他信息非常混亂。 – cel