[H-GEN] ASCII Characters

Greg Black gjb at gbch.net
Sun Oct 26 23:14:45 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, Harry Phillips wrote:
> Trent WADDINGTON wrote:
> 
> >It's even possible
> >to grep -l, which does nothing but print the name of the file in which the
> >match is found.
> 
> Now I will find that switch very handy, I really should read more man pages.

Yes, you should read more man pages -- everybody should read all
man pages.

But you never needed that switch.  The standard shell idiom that
provides exactly the same output as grep -l is this:

    for f in * ; do if grep foo < $f > /dev/null ; then echo $f ; fi ; done

Obviously, you replace "*" with the appropriate filename pattern
and "foo" with the grep pattern you want.  This way, you avoid
the dark side entirely -- and you can even work with older grep
versions without the -l perversion.

And you can still pipe the output of my little exercise above
into other utilities such as xargs, which is another very useful
utility that too many people have not mastered.

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