[H-GEN] ASCII Characters
Greg Black
gjb at gbch.net
Mon Oct 27 19:05:34 EST 2003
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
On 2003-10-27, Michael Anthon wrote:
> On Monday 27 October 2003 14:14, Greg Black wrote:
> <snip>
> > for f in * ; do if grep foo < $f > /dev/null ; then echo $f ; fi ; done
> <snip>
>
> It might produce the same result but I suspect it is somewhat less efficient.
> With going to the effort of actually checking the source I will assume that
> the smart [1] people that added the -l option would have realised that once
> you find the pattern in a file there is no need to keep looking. So, instead
> of telling you you are wrong we do a quick check of the man page and modify
> your method to...
>
> for f in * ; do if grep -m 1 foo < $f > /dev/null ; then echo $f ; fi ; done
On my system, that produces:
grep: invalid option -- m
This was my real point -- there are a million versions of grep,
each with its own perversions.
In fact, I use -l all the time; so I'm not really arguing
against it per se. I was just continuing the original theme a
bit.
> Still avoids -l (which I admit I use a fair bit) but without the performance
> hit of scanning all the files if there is no need. To heda of the
> "processing power and RAM is cheap" crowd, consider that I have over 50G of
> text files on a netware file server that I occasionally need to grep through.
This raises a different question. If I find myself regularly
doing something that takes what I consider to be an unacceptable
amount of time, then I look for a new tool. In the case above,
the tool is glimpse.
However, if my little command line above runs "fast enough",
then I'm going to keep using it.
Cheers, Greg
--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'. See http://www.humbug.org.au/
More information about the General
mailing list