macos - 如何在 Mac OS 上安装 GNU grep?
问题描述
我需要在我的 Mac 上安装 GNU grep,但我发现了一些困难。
我试过这样做:
brew install grep --with-default-names
但这不再是一个选项,因为 Homebrew 已删除--with-default-names
。
任何人都可以为此提供解决方案吗?
解决方案
是的,--with-default-names
被删除了。
但是一些公式,如grep
,为此提供了一种解决方法:
$ brew info grep
...
==> Caveats
All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
...
首先,要安装,只需不install
使用--with-default-names
.
$ brew install grep
...
==> Summary
/usr/local/Cellar/grep/3.3: 21 files, 880.7KB
您还应该看到我在开始时提到的相同“警告”信息。现在,默认情况下,Homebrewgrep
会以“g”为前缀,因此它可以作为ggrep
.
$ ggrep -V
ggrep (GNU grep) 3.3
Packaged by Homebrew
Copyright (C) 2018 Free Software Foundation, Inc.
...
grep
这可以防止它影响Mac 附带的内置功能。
$ grep -V
grep (BSD grep) 2.5.1-FreeBSD
如果您确实需要使用grep
而不是ggrep
,只需按照说明将/usr/local/opt/grep/libexec/gnubin放在PATH
. 您必须在.bashrc或.bash_profile(无论您使用哪个)中执行此操作。
$ echo 'export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ grep -V
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep (GNU grep) 3.3
Packaged by Homebrew
...
推荐阅读
- flutter - 如何获取音频文件的长度而不在 Flutter/Dart 中播放
- php - phpseclib 1.0 是否与 PHP 7.3 兼容?
- node.js - Mongoose document.save() 抛出“验证失败”
- r - SMOTE 有超过 2 个班级?
- curly-braces - clang 格式可以在所有控制语句主体上强制支撑吗?
- javascript - 使用 javascript 和 ajax 从 mysql 获取数据时出错
- java - Spring Boot 不注入具有 Web 感知范围的 Bean
- typescript - 赛普拉斯在开玩笑断言中导致类型错误
- ajax - 如何触发
我需要触发面板内的 ajax 事件,并且面板位于 ac:forEach 内,我该怎么做?我尝试这样做并放置示例的方式,它不会触发 bean 中的事件。
这是xhtml:
<p:panel header="Configuração de Dashboard"> <p:d
- vb.net - 如何从我的表单上的按钮单击另一个程序上的按钮?