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

发布于 2024-11-03 16:29:45 字数 141 浏览 4 评论 0原文

看来xargs并没有一次性传递所有参数,在手册中说xargs 执行命令(默认为/bin/echo)一次或多次,我听说原因这就是 xargs 将传入的参数分成组,然后将它们分组传递给命令。如果这是正确的,有人知道这个组的大小是如何确定的吗?谢谢

It seems that xargs doesn't pass all the arguments at once, in says in the manual that xargs executes the command (default is /bin/echo) one or more times, I heard that the reason for this is that xargs chops the passed in arguments into groups and pass them to the command group by group. If this is correct, anyone knows how this group size is determined? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2024-11-10 16:29:45

使用 --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 选项可用于发现当前系统上有效的实际限制。

Use the --show-limits argument. It will list the existing limits on your system.

$ 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

The group size depends on the length of each argument passed in and the limits listed above.

From the xargs man page, for reference:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文