Yes, it is Unix! First of all you may check if there is the command ggrep (it is not a typo: ggrep with double g) that is the GNU version of grep that could be installed on Unix. In this case use ggrep instead of grep in the example above.
If not, here is a little gawk code that does the trick:
Code:
/Xml To Publish : / {
for (i = 5; i > 0; i--)
if ( (NR - i) in lines ) {
print lines[NR - i]
delete lines[NR - i]
}
below = NR + 5
}
NR <= below { print; next }
{ lines[NR] = $0 }
Save this in a file called (e.g.) script.awk, then execute the command
Code:
awk -f script.awk mylogfile.log
But sincerely I don't know if it works with the awk on Unix. I tested it with gawk (the GNU version of awk). Check if the command gawk exists on the Unix machine: