似乎xargs没有立即传递所有参数,在xargs executes the command (default is /bin/echo) one or more times的手册中说,我听说这是因为xargs将传入的参数分组并将它们传递给命令组 组。 如果这是正确的,任何人都知道如何确定这个组的大小? 谢谢
使用--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
组大小取决于传入的每个参数的长度和上面列出的限制。
从xargs手册页,以供参考:
The POSIX standard allows implementations to have a limit on the size of arguments to the exec functions. This limit could be as low as 4096 bytes including the size of the environment. For scripts to be portable, they must not rely on a larger value. However, I know of no implementation whose actual limit is that small. The --show-limits option can be used to discover the actual limits in force on the current system.
这很好,谢谢。
具有讽刺意味的是,--show-limits选项不是xargs的POSIX标准的一部分,因此您不能依赖它。 (我认为这是GNU扩展。)