This is a pretty simple thing, but something that I never really thought about looking up. If you want to search a file for multiple terms and see all the lines with line numbers so you can note that, in the past I might do something like this:
<shell>: cat -n geo2.pl |grep 143
<shell>: 9 $xml = "1439087.gpx";
Which of course would work, but that would only give me one line of output for that one word, and then I would have to do the same thing again for each term I wanted to search for.
With "egrep" you can use multiple terms conditionally with | then you would get all the terms and lines associated in one command like this:
<shell>: 3:nicolae
<shell>: 5:apollyon
<shell>: 9:desecration
As you can see I looked for any of those words in that file and got back its existence and on what line it was found. Could be very handy.
There are TONS of things you can do with egrep it is very powerful so to learn more hit the command line with "man egrep" and RTFM. :o)

[this is good] It agree, a useful phrase
Posted by: Scott Feldman | 05/22/2010 at 01:56 AM