Counting number of times each IP address appears in log file
You're looking for uniq -c
If the output of that is not to your liking, it can be parsed and reformatted readily.
For example:
$ uniq -c logfile.txt | awk '{print $2": "$1}'
27.33.65.2: 2
58.161.137.7: 1
121.50.198.5: 1
184.173.187.1: 3
uniq
seems to be the cleverer solution, indeed. The awk way:
awk '{ip_count[$0]++}; '\
'END {for (ip in ip_count) printf "%15s: %d\n",ip,ip_count[ip];}' file