So here is the command:
terminal$ sort yourfilename.txt | uniq -c
Here yourfilename.txt can be any file name which I used here for an example.
Suppose the contents of yourfilename.txt be
The sort command is quite self explanatory over here its output is piped/redirected to uniq. Uniq command requires its input to be sorted(keep in mind always hard to remember). Uniq -c just prints the count of each line.