[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get the default value of --max-args?

From: Bernhard Voelker
Subject: Re: How to get the default value of --max-args?
Date: Thu, 8 Nov 2018 11:50:29 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

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':

       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

echo called only once:

  $ yes . | head -n $(bc <<<'131072 /2 - 3') | xargs -tn 200000 2>&1 | tr -d 
'[. ]'

echo called twice:

  $ yes . | head -n $(bc <<<'131072 /2 - 2') | xargs -tn 200000 2>&1 | tr -d 
'[. ]'

Have a nice day,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]