Re: Argument list too long: out of environment space

From: Jesse Pollard (pollard@tomcat.admin.navo.hpc.mil)
Date: Wed Mar 01 2000 - 18:36:58 EST


Richard B. Johnson" <root@chaos.analogic.com>:
> On Thu, 2 Mar 2000, Stuart Inglis wrote:
>
> > Hi all,
> >
> > I have 9600 files in a directory and have troubles processing them. I
> > thought it was a bash problem but Chet Ramey kindly informed me that
> > it's a Linux kernel limitation.
> >
> > bash-2.03$ cd tttt/
> > bash-2.03$ echo * | wc
> > 1 9569 279676
> > bash-2.03$ getconf ARG_MAX
> > 131072
> > bash-2.03$ grep hello *
> > bash: /bin/grep: Argument list too long
> > bash-2.03$ sort *
> > bash: /bin/sort: Argument list too long
> > bash-2.03$
> >
> > Why is this limit so small? There are only 9600 files taking a total of
> > less than 300k to specify all of the names. The machine has 100's of Mb
> > of RAM. Is it easy to change/fix?
> >
> > cheers
> > Stuart
>
> It's the length of the command line. What you are doing when you expand
> the wildcards is to put every filename on the command-line. I don't
> think this is what you want to do. If it is what you want to do, then
> well,... I don't think anybody can help.

Can't help with the command line limit, but there is A Better Way:

For the example given:
        grep hello *
becomes:
        find . -type f -exec grep hello '{}' ';'

I assume the sort * is to merge the data:

find . -type f -print | while read v; do ; cat $v; done | sort

Where there is a shell, there is a way...
-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil

Any opinions expressed are solely my own.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:11 EST