Background
Sometimes it’s useful to see how many times a specific IP address appears in a log file. In this article we explore one method using grep
and uniq
.
grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" /path/to/sourcefile | sort > output.txt
then
uniq -c output.txt | awk '{print $2": "$1}'