grep * to search a whole directory

I was trying to find a networking test from xenophile in my irc logs today, but I just couldn’t remember where it would have been. Fortunately, this is easy with *nix.

grep lets me search text for a string of text, and I know I was looking for xenophile, so:
grep xenophile

But, I don’t even know whether his name is capitalized or not! Adding -i will ignore case:
grep -i xenophile

Now, which log was that in? I have about 60 of them lying around in this directory… I guess I’ll search all of them:
grep -i xenophile *

Whoah, that was about 1200 lines of text (xenophile apparently talks a lot). Lets make that a little more manageable and put the output in a tmp file:
grep -i xenophile * > tmp

Ok, now I can just search that one file for the text I’m looking for. I know he was saying something about a test:
grep -i test tmp

There. Only eight lines of text, and the second line is the one I was looking for.

Or, I could’ve just done this all in one line:
grep -i xenophile * | grep -i test


Posted

in

by

Tags:

Comments

3 responses to “grep * to search a whole directory”

  1. […] My wife loves me dearly, but I risk losing even her readership every time I post something extremely geeky. You probably love me even less then her. So I run an even greater risk with you. […]

  2. Christopher Neitzert Avatar

    did you find it? I still have it.

    1. thomasknoll Avatar

      Oh, yeah… found it long ago. Was just talking about *how* I found it. =)

Leave a Reply to .:dydimustk:. » Blog Archive » clarityCancel reply