Argument list too long
Chris Ross
cross+freebsd at distal.com
Thu Mar 7 16:35:02 UTC 2013
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?
>>
>> # ll | wc -l
>> 11467
>>
>> # grep X-PHP-Script * | more
>> /sbin/grep: Argument list too long.
>>
>> # egrep X-PHP-Script *.ua | more
>> /usr/sbin/egrep: Argument list too long.
>>
>> # cat *.ua | grep X-PHP-Script | more
>> /sbin/cat: Argument list too long.
>>
>
> Your shell can't process that many arguments. Use this:
>
> grep -R "X-PHP-Script" .
>
> or if you don't want to descent into subdirectories:
>
> 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
More information about the freebsd-fs
mailing list