awk programming

I have the list of numbers in a file

105.1
102.0
100.5
100
98
97.5
95
...

I want to get how many times I have numbers greater than a particular limit, say 100 in the list. How can I do that with awk command?

This is pretty straight: all you need to do is to initialize a variable, say, count, to zero and then increment it whenever you find a value that matches the condition. Of course, there are different ways you can think how to test the condition:

'BEGIN { count=0 }  $1 >= 100  { count++} END {print count}'
'BEGIN { count=0 }  { if($1 >= 100) count++} END {print count}'

I think that the first one is more like the awk way of thinking.

Another way ;):

awk '$1 >= 100{c++} END{print c}' file

thanks pflynn, I have already tried this suggestion, its giving me wrong value ...don't know why, I have 5 values above 100, returned value is 7

Hmmm...this is AWKward :smiley: ! Are you sure the sample file has exactly the same format you posted here? Is it too big? Can you post it here? And just to get attention: you originaly asked how to count the numbers greater than a particular limit, but the proposed solutions here will give you the count of the numbers greater than or equal to this limit (100, in this case), could it be the problem?

All of the suggested scripts work fine.
eg:

echo "105.1
102.0
100.5
100
98
97.5
95" | awk '$1 >= 100{c++} END{print c}'
4