[H-GEN] ASCII Characters
Michael Anthon
michael at anthon.net
Mon Oct 27 06:36:28 EST 2003
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
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
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.
I'm only able to access said files from my Win2k workstation (thank god for
cygwin!)
Cheers,
Michael
[1] I'm assuming they are smart, they keep telling us so...
--
* 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