On Sunday 19 November 2006 11:29 am, Chris wrote: > > 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. > > That seems to give me the same output as first noted: > > [EMAIL PROTECTED] cur]$ ls * | xargs grep -l 20773 /dev/null > bash: /bin/ls: Argument list too long
Oops - that's why you use find. Not sure why I suggested ls(), must have had a brain phart. And I tend to put /dev/null on the grep so that it always has more than one argument and lists the file name even when grepping w/o the "-l". Heck, I'm still getting used to a find whose default action is to print the matching filenames. ____________________________________________________ Want to buy your Pack or Services from Mandriva? Go to http://store.mandriva.com Join the Club : http://www.mandrivaclub.com ____________________________________________________
