sudo and xargs disagree about maximum command line length

Björn König bkoenig at cs.tu-berlin.de
Wed Aug 10 20:56:31 GMT 2005


Stijn Hoop wrote:

> I think the below should not happen:
> 
> [stijn at tangaloor] </net/freebsd/ports> find . | grep CVS/Root | xargs sudo -u src sed -i.bak -e 's#/freebsd#/net/freebsd#'
> sudo: unable to execute /usr/bin/sed: Argument list too long
> sudo: unable to execute /usr/bin/sed: Argument list too long
> sudo: unable to execute /usr/bin/sed: Argument list too long
> sudo: unable to execute /usr/bin/sed: Argument list too long
> 
> Is there a sudo knob that should be tweaked?

Use the parameter -L of xargs

   ... | xargs -L3 command

xargs will pass only three lines from input as argument to the command, 
i.e. it executes

   command line1 line2 line3
   command line4 line5 line6
   ...

instead of

   command line1 line2 line3 line4 line5 line6 ...

which often causes 'Argument list too long'.

Regards Björn


-- 
Björn König (bkoenig at cs.tu-berlin.de)
student at the Technische Universität Berlin
http://bkoenig.alpha-tierchen.de/


More information about the freebsd-ports mailing list