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. ____________________________________________________ Want to buy your Pack or Services from Mandriva? Go to http://store.mandriva.com Join the Club : http://www.mandrivaclub.com ____________________________________________________
