Logic for multiple if conditions.

Hi Gurus,
Is there a way we can set a logic for this problem ?

The input file looks like below;

1 15 17
2  8 12
3 18 24
4 21 23
5 2 4
6 11 25

So, I would like to print for any row of the input file where the range of value between $2 to $3 lies within the min and max values of

Min=10 and Max=20

.

The o/p file should look like -

1 15 17
2  8 12
3 18 24
6 11 25

Thanks,

Try:

awk '($2>=10 && $2<=20) || ($3>=10 && $3<=20)' file

The following assumptions have been made based upon your output:

  • If $2 OR $3 are within the min/max range, then print the row. Not $2 AND $3.
  • Clauses >= and <= have been used rather than > and <
1 Like

Many thanks Pilnet101