I have a file that will sometimes contain a pattern. The pattern is this:
FRM CHK 0000
I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below.
I have a file that will sometimes contain a pattern. The pattern is this:
FRM CHK 0000
I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below.
nawk ' /FRM CHK 0000/ { getline;getline;RECORD="" } !/FRM CHK 0000/ { if ( RECORD != "" ) print RECORD; RECORD=$0 } END { if ( RECORD != "" ) print RECORD } ' file
awk '
/FRM CHK 0000/ { print last; print; x = 1; next }
x == 1 { print; x = 0 }
{ last = $0 }
' "$FILE"
pmm - we don't have nawk on our system. Thanks though.
cfajohnson- your script prints the lines I am looking for. I am looking to delete those lines (and print everything except those lines).
I got this from phv and it works good.
awk '
/FRM CHK 000000/{x="";getline;next}
{if(x)print x;x=$0}
END{if(x)print x}
' filename