Parse an Nginx access log and print the top 10 client IPs by request count.

BeginnerHands-onBash scripting tasks
Answer
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -10

Key trick → uniq -c only collapses adjacent lines, so you must sort before it, then sort -rn to rank by the count.

All Real-World Interview questions Roadmap: Interview readiness

More on Bash scripting tasks