Barebones web statistics in 1 line of bash
My friend is hosting some MP3s on my server, and he wondered if there was an easy way for him to see what the daily download rate was like. I'm a bum who hasn't set up a proper analytic tool, so after An Inappropriately Long Duration of hacking, this is what I came up with:
while true; do ( echo "HTTP/1.0 200 Ok"; echo; echo "<PRE>$(cat /var/sites/kenpachi/log/access.log | grep `date +%d\\/%b` | grep -o "GET .*\.mp3" | grep -v 404 | sed -e"s_GET /~jwiswell/__" | sort | uniq -c | sort)</PRE>" ) | nc -q1 -l -p8081; done
There's probably a better way to do the text munging with awk, but, I tried. I was reminded of this by the "one-shot fileserver" in the Command Line Tricks post (http://news.ycombinator.com/item?id=958494).