7

我在 Mac 上,不想使用内置xargs实用程序。因为它与 gnu 不同xargs。在google周围我发现xargs属于findutilshomebrew中的包,我可以用一个简单的命令安装它brew install findutils。我的问题是,有没有更简单的方法来识别xargs属于findutils

谢谢。

4

2 回答 2

23

brew search --desc xargs

会给出结果

findutils: Collection of GNU find, xargs, and locate

--desc在描述中搜索时需要该选项。它不会在每个包提供的文件列表中进行搜索。我相信这可能是不可能的,因为 brew 的公式不包括这个文件列表。

于 2016-09-09T13:34:01.487 回答
0

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.bashrcxargs

要查看xargs当前 shell 中使用的是哪个版本:

which -a xargs
于 2022-02-22T14:04:03.137 回答