linux命令xargs:它传递的参数的最大大小?

use*_*275 9 linux size command xargs limit

似乎xargs没有立即传递所有参数,在xargs的手册中说executes the command (default is /bin/echo) one or more times,我听说这是因为xargs将传入的参数分组并将它们按组传递给命令组.如果这是正确的,任何人都知道如何确定这个组的大小?谢谢

Mat*_*Mat 19

使用--show-limits参数.它将列出您系统的现有限制.

$ xargs --show-limits
Your environment variables take up 4108 bytes
POSIX upper limit on argument length (this system): 2090996
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2086888
Size of command buffer we are actually using: 131072
Run Code Online (Sandbox Code Playgroud)

组大小取决于传入的每个参数的长度和上面列出的限制.

xargs手册页中,供参考:

POSIX标准允许实现限制exec函数的参数大小.此限制可能低至4096字节,包括环境的大小.要使脚本可移植,它们不能依赖更大的值.但是,我知道没有实施,其实际限制很小.--show-limits选项可用于发现当前系统的实际有效限制.

  • 具有讽刺意味的是,`--show-limits` 选项 [不是`xargs` POSIX 标准的一部分](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html),所以你可以'不依赖它。(我认为这是一个 GNU 扩展。) (2认同)