Unix Gurus,
I have been breaking my head to get this done..seems simple..
I need to read a flat file and based on a key word in a line, i need to skip the previous 3 lines.
eg :
Line1
Line2
Line3
Line4
Line5
Line6
Error
Line7
Line8
Line9
Error
Line10
Line11
Line12
I will read this file, and awk for the first word. If the first word is 'Error', then i need to skip the previous 3 lines.
At the end collect the o/p into another file or display.
The above example at the end should look like :
Line1
Line2
Line3
Line10
Line11
Line12
I tried going the sed way,
sed -n '/Error/{N;N;N;p;}' will give me the nexe 3 lines,
but my requirement is to skip the previous 3 lines.
I tried by reading the file in reverse ( tail -r file ) and then using sed.
With this i can get the 3 lines that i want, but how to skip these lines...i need to get everything in the file except these 3 lines !
Any help is appreciated.
Thanks,
R.