Hi All,
OS-Type=Sun-OS 5.8 Sparc9 Processor
Can I grep the previous 4 lines and next 4 lines of a matched pattern(context grep)?
For example here we need to monitor logs of live traffic.The data obtained from "tail -f LiveTrafficData.log"
looks something like this:-
----------------------------
Sender-ip=10.123.32.34 //Useful Info
Junk Parameter=blah
Blah Parameter=more blah
Packet-state=start //Useful Info
Policy-type=test-value-policy //Useful Info
Some more blah
blah blah
user-profile-type=host
user-location=njs-234 //Useful Info
....
...
Similar sort of repetitive data
-------------------------------
Now here the lines which are of concern to me are only policy-type,packet-state,service-ip and user-location,
i.e., I need to ascertain sender-ip and user-location only and only when Policy-type=<desired pattern> AND
Packet-state=<desired pattern2>.
Also note it is from live traffic, so we need to work on "tail -f" of whatever log we are getting,i.e. we need to work on Standard Input and not file.
Any help is welcome.
Thanks and Regards.
P.S:-I went through the internet,but I dont have "grep -A num" or "vmsgrep" or "cgrep".
Also,as it is fresh and accumulating log,so I probably cant store in a file, ie I need to work on Standard Input,not file