On Thu, Nov 8, 2018 at 4:50 AM Bernhard Voelker <m...@bernhard-voelker.de> wrote: > > On 11/8/18 6:50 AM, Peng Yu wrote: > > Hi, > > > > It seems that the default value for --max-args is system dependent. Is > > there a way to find out its default value? Thanks. > > Actually the limit is not a matter of the number of arguments but that > of the resulting total command line length. > > From 'man xargs': > > --show-limits > Display the limits on the command-line length which are imposed by the > operating system, xargs' choice of buffer size and the -s option. > Pipe the input from /dev/null (and perhaps specify --no-run-if-empty) > if you don't want xargs to do anything. > > So here it is: > > $ xargs --show-limits </dev/null > Your environment variables take up 3163 bytes > POSIX upper limit on argument length (this system): 2091941 > POSIX smallest allowable upper limit on argument length (all systems): 4096 > Maximum length of command we could actually use: 2088778 > Size of command buffer we are actually using: 131072 > Maximum parallelism (--max-procs must be no greater): 2147483647 > > It's "actually using: 131072". > > So even if you specify a higher number like 'xargs -n 200000', and all the > arguments only have 1 character, then still the number of actual arguments > for each program execution cannot be larger than about 131072/2 minus a few > bytes: > > echo called only once: > > $ yes . | head -n $(bc <<<'131072 /2 - 3') | xargs -tn 200000 2>&1 | tr -d > '[. ]' > echo > > echo called twice: > > $ yes . | head -n $(bc <<<'131072 /2 - 2') | xargs -tn 200000 2>&1 | tr -d > '[. ]' > echo > echo
Thanks. But I am not getting the same results (not the same number of echo's) as yours. I am using Mac OS X. Do you know why it is different? $ xargs --show-limits < /dev/null Your environment variables take up 7701 bytes POSIX upper limit on argument length (this system): 252395 POSIX smallest allowable upper limit on argument length (all systems): 4096 Maximum length of command we could actually use: 244694 Size of command buffer we are actually using: 131072 Maximum parallelism (--max-procs must be no greater): 2147483647 $ yes . | head -n $(bc <<< '131072/2 - 3') | xargs -tn 200000 2>&1 | tr -d '[. ]' echo echo echo echo echo echo echo echo echo $ yes . | head -n $(bc <<< '131072/2 - 2') | xargs -tn 200000 2>&1 | tr -d '[. ]' echo echo echo echo echo echo echo echo echo -- Regards, Peng