【问题标题】:linux command xargs: maximum size of the arguments passed by it?linux命令xargs:传递的参数的最大大小呢?
【发布时间】:2011-08-11 22:40:03
【问题描述】:

似乎 xargs 不会一次传递所有参数,在手册中说 xargs executes the command (default is /bin/echo) one or more times,我听说这样做的原因是 xargs 将传入的参数分成组并将它们传递给一组一组的命令。如果这是正确的,有谁知道这个组的大小是如何确定的?谢谢

【问题讨论】:

    标签: linux command size limit xargs


    【解决方案1】:

    使用--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 手册页,供参考:

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-16
    • 1970-01-01
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 2014-01-09
    • 2011-10-14
    相关资源
    最近更新 更多