我在 Mac 上,不想使用内置xargs
实用程序。因为它与 gnu 不同xargs
。在google周围我发现xargs
属于findutils
homebrew中的包,我可以用一个简单的命令安装它brew install findutils
。我的问题是,有没有更简单的方法来识别xargs
属于findutils
?
谢谢。
我在 Mac 上,不想使用内置xargs
实用程序。因为它与 gnu 不同xargs
。在google周围我发现xargs
属于findutils
homebrew中的包,我可以用一个简单的命令安装它brew install findutils
。我的问题是,有没有更简单的方法来识别xargs
属于findutils
?
谢谢。
brew search --desc xargs
会给出结果
findutils: Collection of GNU find, xargs, and locate
--desc
在描述中搜索时需要该选项。它不会在每个包提供的文件列表中进行搜索。我相信这可能是不可能的,因为 brew 的公式不包括这个文件列表。
brew install findutils
安装xargs
符号链接,/usr/local/bin/gxargs
因此与 macos ootb 没有名称冲突/usr/bin/xargs
。
在安装过程中,brew
请注意将显示的以下消息:
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/findutils/libexec/gnubin:$PATH"
如果您确实将上面的行添加到您的.zshrc
或.bashrc
将被调用的版本将取决于您的脚本将运行的环境。例如,cron
不会使用您的or并且因此将调用 ootb 。.zshrc
.bashrc
xargs
要查看xargs
当前 shell 中使用的是哪个版本:
which -a xargs