Interview Prep/Linux/Packages, Shell & Text Tools

Show practical awk usage.

IntermediateConceptPackages, Shell & Text Tools
Answer

awk processes text line by line, splitting into fields ($1, $2, NF, NR).

awk '{print $1}' access.log | sort | uniq -c | sort -rn | head    # top client IPs
awk '$9 >= 500 {c++} END {print c}' access.log                  # count 5xx
awk -F: '$3 >= 1000 {print $1}' /etc/passwd                      # regular users
df -P | awk 'NR>1 && $5+0 > 80 {print $6, $5}'                    # mounts over 80%
All Linux questions Roadmap: Linux

More on Packages, Shell & Text Tools