I know only a litte bit of scripting and sed and started using awk recently.
I have a scenario where if the first 4 characters of a line are "PASS" I need to delete that line and the 2 lines below that from the file. I was looking at sed and awk one liners page and nothing really suited me for this requirement however they helped me with some of teh other reqs.
I tried
and
They dont seem to work.
Sample data
I have a scenario where if the first 4 characters of a line are "PASS" I need to delete that line and the 2 lines below that from the file. I was looking at sed and awk one liners page and nothing really suited me for this requirement however they helped me with some of teh other reqs.
I tried
Code:
awk '/^PASS/ { if (substr($0, 0, 4) == "PASS") ;else print }' testfile
Code:
awk '/^PASS/{print x};{x=$0}'
They dont seem to work.
Sample data
Code:
TEST
PASS1
ABC
DEF
GHI
PASS2
JKL
MNO
PASS3
PQR
XYZ
123