find frequency

Hi,

I have a file with more than 1 million records.. Each row has a distance number.. I want to know how many times is each number occurring from min to max number..

2
5
120
208
7
28
45
6
33
120
7
208
so onn..

output
0-0
1-0
2-1
3-0
4-0
5-1
6-1
7-2
so on 208-2

Thanks,

awk '{count[$1]++}END{for(j in count) print j,"- "count[j]""}' yourfile.txt

Try this:

 
awk '{
 c[$1]++; 
 if($1 < min) min=$1; 
 if($1 > max) max=$1;
}END{
  for(i=min; i<=max; i++){
     print i "-" (c?c:0) }
}' freqData.txt 
awk 'BEGIN{max=0}{
c[$1]++;
if($1 > max){max=$1}
}
END{for(i=0;i<=max;i++)
	{ print i"-"(c?c:0)
	}
}' filename

Try this very simple approach:

sort -n filename|uniq -c

if you can afford losing the zero occurrences.