The grep programs have one very handy feature: they can select lines that don't match a pattern just as they can select the lines that do. Simply use the -v option.
I used this most recently when working on this book. We have thousands of separate files under RCS (20.14) and I sometimes forget which ones I've got checked out. Since there's a lot of clutter in the directory, and several people working there, a simple ls won't do. So I use a find alias to list only the files belonging to me. (It's a version of the find alias described in article 17.23, with -user tim added to select only my own files.)
Believe it or not, even that isn't specific enough.
There are a
variety of temporary files created by some of our printing scripts that I
don't want to see.
All of these files have names beginning with a
comma (,
), so when I want to see which files I might have forgotten to
check back in to RCS, I type:
%find. | grep -v ,
Obviously, that's about as specific, non-reproducible an example as you're likely to find anywhere! But it's precisely these kinds of special cases that call for a rich vocabulary of tips and tricks. You'll never have to use grep -v for this particular purpose, but you'll find a use for it someday.
-