I have a text file. It contains some line like this:-
I don't want to see this line 1 and next line.
exception: 14
I want to see this line 1 and next line.
exception: 16
I don't want to see this line 2 and next line.
exception: 13
I want to see this line 2 and next line.
exception: 19
I want the output like this:-
I want to see this line 1 and next line.
exception: 16
I want to see this line 2 and next line.
exception 19
I tried to use awk to solve it. But cannot get the right result. My awk script:
$ cat test.awk
awk '
{if ( $2 > 14 ) print prev $0; next}
' test.txt
Result:
$ ./test.awk
I don't want to see this line 1 and next line.
I want to see this line 1 and next line.
exception: 16
I don't want to see this line 2 and next line.
I want to see this line 2 and next line.
exception: 19