On Sunday, 19 November 2006 18:23, Russ Kepler wrote:
> On Sunday 19 November 2006 08:12 am, Chris wrote:
> > Quick question maybe someone can answer. I'm trying to grep a number in a
> > group of messages in my maildir file. There are 4000 messages in this
> > folder and when running grep -l 20773 * I get an "Argument list too long"
> > which I've come to realize is because of the number of messages, in this
> > case, it has to look through. Is there a simple work around for this or
> > will I have to work in blocks of say, 1000?
>
> Rather than a for loop the best way to handle this is to use xargs(). 
> xargs() collects the list as input and doles it out in maximum argument
> list length pieces.  The advantage of this is that you're not starting one
> copy of the command per argument but instead one for several hundred.  In
> your case I'd use:  "ls * | xargs grep -l 20773 /dev/null". The "/dev/null"
> is to make sure that the grep gets an argument.  I'd likely use "find . |
> grep..." to depth search the tree from the current directory.  I do that a
> lot from my home directory as I'm always losing stuff.

The "/dev/null" is not necessary, since xargs provides the argument to the 
grep command.

cheers
Duncan

                
___________________________________________________________ 
The all-new Yahoo! Mail goes wherever you go - free your email address from 
your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
____________________________________________________
Want to buy your Pack or Services from Mandriva? 
Go to http://store.mandriva.com
Join the Club : http://www.mandrivaclub.com
____________________________________________________

Reply via email to