I was afraid my explanation would be vague. Lemme try to be more specific.
Suppose the following three alarms are in a log file:
Wed Feb 2 07:02:22 <vsm> 91041 Line 37 Severity 4 Vps 8
No Host Found - TN:2135572346
Wed Feb 2 07:02:22 <vsm> 91041 Line 23 Severity 4 Vps 3
No Host Found - TN:2156772216
Wed Feb 2 07:02:22 <vsm> 91041 Line 12 Severity 4 Vps 1
No Host Found - TN:2165523456
Now...let's suppose that the only one I really care about is the one in blue. What I want to do is prompt a user to tell me the "Line" number, then the "Vps" number. So for this example, the user would input Line 23 and Vps 3.
The script would then look at all 91041 alarms, find the one(s) for Line 23 and Vps 3, then report them back to me. As a bonus, it would also report the second line of the 91041 alarm to me, which is important because it has the TN. In other words, after running my script, one would see:
Wed Feb 2 07:02:22 <vsm> 91041 Line 23 Severity 4 Vps 3
No Host Found - TN:2156772216
This is almost exactly what I need, but I need to get the line before the match as well as some lines after it. How would I get the line before the match? I also do not have the -B and -A options or ggrep.
Thanks.
EDIT: I continued playing around with it and beating my head against the wall. I got this and it seems to work:
sed -n -e /regex/ {=;x;p;g;N;p;D;}' -e h searchfile
Here is a usefull script that might be what you need...
It's a perl script that is a windowing grep that is useful for grabbing X number of lines before and after a match.