简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM