r/ScriptSwap • u/Alkanes123 • Dec 17 '17
[help] simple shell script
Hi everyone,
I need help with a simple shell script that can count the number of http 4xx responses per unique ip address in the server access logs at /var/logs/httpd/access_logs
I found this online but doesn’t help much since it tell me the count for all response codes without IP
cat access_log | cut -d ‘“‘ -f3 | cut -d ‘ ‘ -f2 | sort |uniq -c | sort -rn
Please can someone help me? Thank you!
2
Upvotes
View all comments
Show parent comment
1
u/joedonut Dec 18 '17
count, so it's likeuniq | wc -lbut saving a little overhead. It does only count lines-with, not real occurrences I think. I think GNU uniq had it first and it came later to V-ish Solaris and BSD-ish OSX, BICBW.