-2

My test file is

1599027 48.5
1599027 29.7
1599028 49.9
1599028 19.4
1599029 49.5
1599026 19.2
1599026 19.2

from this I need to get the number from the first column which should have the second column value <30 in all its representing lines.In the above test file, only one number '1599026' which matches the above criteria(both the listed lines are having 19.2 which is <30). The other two numbers in the first column has >30 in one of the lines.

1 Answer 1

1
$ awk '{ sum[$1] += ($2 >= 30) } END { for (i in sum) if (!sum[i]) print i }' file
1599026

This uses awk to create a sum for each unique number in the first column of your data in the file called file. The sum for a number is the number of times the second column's value is greater than or equal to 30.

At the end of the awk code, in the END block, all numbers with a zero sum are printed.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.