how to do arithmetic operations in one line command

I have a file like this

product   qty1   qty2	value
cola        50	25	1
pepsi      100     75	2
muffin     25	30	0.5

would like to do the following operations with one line command

1) disply the line having "Qty1" greater than or equal to 50
2) display the line Qty1 - Qty2 greater than 20

Need a simple one line command to do these mathematical operations and take decision

thank you in advance

awk '(NR>1) && (($2>=50) || ( ($3-$2)>20))' datafile

The (NR>1) && is just to prevent it from printing that first line with all the titles, if your data doesn't really have that lop it off.

1 Like
awk '$2>=50||$2-$3>20' file