I would like to grep a word and then find the second column in the line and check if it is bigger than a value. Is yes, I want to print the previous line.
Ex:
In
This can be a way:
$ awk '$1=="BB" && $2>1 {print f} {f=$1}' file
AAAAAAAAAAAAA
$1=="BB" && $2>1 {print f}
if the 1st field is exactly BB
and 2nd field is bigger than 1
, then print f
, a stored value.{f=$1}
store the current line in f
, so that it is accessible when reading the next line.