Skip to content

Instantly share code, notes, and snippets.

@coboshm
Created February 8, 2015 22:03
Show Gist options
  • Save coboshm/fa40190cd039eb68ade9 to your computer and use it in GitHub Desktop.
Save coboshm/fa40190cd039eb68ade9 to your computer and use it in GitHub Desktop.
Access.log get the first five ip with more visits and the number of visits
#!/bin/bash
# Author: Marc Cobos
FILE=test.access.log
for ip in `cat $FILE |cut -d ' ' -f 1 |sort |uniq`;
do
COUNT=`grep ^$ip $FILE |wc -l`;
echo $COUNT ' : ' $ip
done | sort -rn -k1 | head -5
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment