RSS Amplifier

Satyam Sundaram's Explorations · Dec 17, 2025

Sadservers.com Solution for: "Saskatoon": counting IPs.

0
Sign in to vote or save

This page did not load. You can still read it on the original site — the toolbar below keeps your place in the directory.

Question details: https://sadservers.com/scenario/saskatoon # inspect logs less /home/admin/access.log # print first word of each line (space is separator) awk '{print $1}' /home/admin/access.log # we need count of all IPs which we'll get with uniq...

Question details: https://sadservers.com/scenario/saskatoon

# inspect logs
less /home/admin/access.log
# print first word of each line (space is separator)
awk '{print $1}' /home/admin/access.log
# we need count of all IPs which we'll get with uniq -c but for that first we need to sort
# because uniq -c only counts strings as similar if they are adjacent to each other
# sort would help us group all similar IPs together
awk '{print $1}' /home/admin/access.log | sort
# get count of each IP
awk '{print $1}' /home/admin/access.log | sort | uniq -c
# the output of uniq -c is not sorted by frequency of each IP
# it just contains <frequency> <ip> when it saw that group, so we need to sort it by frequency in descending order
# sort by default sorts lexicographically, -n is to sort numerically, -r is for reverse
awk '{print $1}' /home/admin/access.log | sort | uniq -c | sort -nr
# print first line
awk '{print $1}' /home/admin/access.log | sort | uniq -c | sort -nr | head -n 1
# print second word of each line (only 1 line here)
awk '{print $1}' /home/admin/access.log | sort | uniq -c | sort -nr | head -n 1 | awk '{print $2}' > /home/admin/highestip.txt
# verify answer
sha1sum /home/admin/highestip.txt
# 6ef426c40652babc0d081d438b9f353709008e93

Go ahead and try it yourself. Explore different commands to do the same thing. → sadservers.com

Share how you would approach the problem in the comments below.

Read on satyamsundaram.hashnode.dev

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.