Counting non-specific occurrences within a file.

I'm pretty new to scripting and didn't see an example of this issue yet. I am trying to count and print the total number of times each value is found within a file. Here is a short example of my starting file.

value	3
value	3
value	3
value	3
value	4
value	6
value	6
value	6
value	6
value	8
value	8
value	8
 

The entire file I am working with is very large and I will not be able to know each value in advance. I'm trying to get to a file that looks like this

value	3	4
value	4	1
value	6	4
value	8	3
...	....	...

with column 3 being the total number of times a specific value (i.e value 3) is found within the file.

I've tried a couple different grep and wc commands but these seem to be fore specific searches. Any help would be appreciated.

Thanks

This should work:

awk '{a[$0]++};END{for(i in a)print i, a}' file

One way would be to use uniq

$ cat in
horse
sheep
cow
sheep
sheep
cow
$ sort in | uniq -c
      2 cow
      1 horse
      3 sheep

But that only works, if the file is not too big to sort.

Thank you!

Both methods seem to work for what I need!