Quick question on grep: grabbing lines above and below

Just a quick question on grep/egrep.

I am writing a shell script that is looking for certain strings in a text file. It works well and gets exactly what I need.

However, the way the program writes to the text file, it puts the timestamp in a line above the string I am looking for and the path below the string I am looking for.

So my question is, how do I grab all three lines in my search? I am thinking I might need to go to something more powerful like awk.

I appreciate the help.

TCG

In the basic implementations of grep, not without putting a lot of shell script round it. In newer version of grep, there's a commandline parameter to display a set number of lines before and after each match. man grep for more info and to see if you have the right version.

Hmm. Ok. I will check it out.

On my particular system, we are running Solaris 9. Not sure if that would support the newer version.

Assuming that I do not have the newer version, any other suggestions?

Thanks.

TCG

Can you show a bit of the file as example?