data extraction

Associate
Joined
6 Jul 2006
Posts
651
Silly question ahoy.

I'm trying to search through a couple hundred log files to find and output each line on screen (and eventually to a file) where the searched for phrase turns up.

I assume this can be done via grep, but I've searched through the man page for grep and can't see how, which is most likely me just being slow, but can someone give me a hand.

The sending to a file I can do with "> filename" but the actual searching multiple files is doing my head in :o
 
Use '*' to select multiple matching files like this:
cat /path/*.log |grep "mathing_line" > /path/file_to_save_results

-n with cat will number output lines. Not sure if that is helpful that much.

Edit: This is a bit longer then doing the actual file selection with grep, but this is easier to remember then how to use grep.
 
Back
Top Bottom