linux 命令 xargs : maximum size of the arguments passed by it?

标签 linux command size limit xargs

xargs 似乎并没有一次传递所有参数,在手册中说 xargs 执行命令(默认为/bin/echo)一次或多次,我听说这样做的原因是 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.

关于linux 命令 xargs : maximum size of the arguments passed by it?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5772156/

相关文章:

c# - 从代码隐藏调用命令

c++ - 二维数组大小

html - 如何在 html/css 中水平制作下拉列表(值彼此相邻)

linux - UART - 在轮询模式下使用 FIFO

c - 您从哪里获得 inode 功能?

linux - 重定向与管道 - 为什么它有效以及为什么它无效

linux - 如何打印/tmp 目录中每个文件除最后 20 行之外的所有内容?

windows - 有什么方法可以重定向在 Windows 命令行中使用 "start"运行的命令的 stderr 输出?

linux - 用于检查 Linux 主机上是否可访问 Linux 存储的 Shell 脚本

c++ - 一个变量中的最大指针数