Q:

how do I count numbers from command line?

1
1
1
2
2
2
3
3

Let's say I have a file contains these numbers, I want to count those numbers like this
(num):(occurence)
1:3
2:3
3:2

How do I do this in shell script?

A:

you can use this
    sort a.dat | uniq -c | awk '{print $2, ":", $1}'

If you really bothered by the white space
   sort a.dat | uniq -c | awk '{print $2":"$1}'

