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

3 comments on “grep * to search a whole directory”

Leave a Reply to .:dydimustk:. » Blog Archive » clarity Cancel reply