-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 19 November 2006 10:23 am, 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.
>
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

[EMAIL PROTECTED] cur]$ ls * | xargs grep -l 20773
bash: /bin/ls: Argument list too long

The tiny script that Hal provided worked just fine for my needs which was 
looking for a certain ASN in over 4000 messages.

- -- 
Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFFYKKT43Kn2pjmcFwRAsW+AJ93qIQM+Uka6GTkE76Do93Pp0RbUQCeL+Kx
SJ/VRCLcoOThCPFirA0c+24=
=exzs
-----END PGP SIGNATURE-----
____________________________________________________
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