Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Mar 2013 11:34:48 -0500
From:      Chris Ross <cross+freebsd@distal.com>
To:        Lars Engels <lars.engels@0x20.net>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: Argument list too long
Message-ID:  <0CABF9B0-5274-44B3-984E-54CCD5C2F687@distal.com>
In-Reply-To: <20130307161546.GV47829@e-new.0x20.net>
References:  <82112.1362671436.13776555968178880512@ffe17.ukr.net> <20130307161546.GV47829@e-new.0x20.net>

next in thread | previous in thread | raw e-mail | index | archive | help

On Mar 7, 2013, at 11:15 AM, Lars Engels wrote:
> On Thu, Mar 07, 2013 at 05:50:36PM +0200, Vladislav Prodan wrote:
>> Why 12K small files from one directory to cause problems?
>>=20
>> # ll | wc -l
>>   11467
>>=20
>> # grep X-PHP-Script * | more
>> /sbin/grep: Argument list too long.
>>=20
>> # egrep X-PHP-Script *.ua | more
>> /usr/sbin/egrep: Argument list too long.
>>=20
>> # cat *.ua | grep X-PHP-Script | more
>> /sbin/cat: Argument list too long.
>>=20
>=20
> Your shell can't process that many arguments. Use this:
>=20
> grep -R "X-PHP-Script" .
>=20
> or if you don't want to descent into subdirectories:
>=20
> find . -type -f -name '*.ua' -maxdepth 1 -exec grep "X-PHP-Script" {} =
\+

  Those solutions will work, but the problem is actually the inability =
of the shell to start a process with that long of an argument list.  =
(ARG_MAX bytes).  The shell can process them, just not hand them off to =
another process via the argument vector.

  echo * | xargs grep X-PHP-Script | more

will also work.  (man xargs for more information)

  Sorry to be a bit pedantic.

                                - Chris




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0CABF9B0-5274-44B3-984E-54CCD5C2F687>