Busiest Visitors
Each line of access.log is a visitor, a page and a status code, with spaces between them: 10.0.0.7 /home 200. Print the three visitors with the most lines, the busiest first, each as its count, a space, and the visitor: 5 10.0.0.7. Visitors with the same count go in order of their name, as text.
Example 1
access.log
10.0.0.7 /home 200 10.0.0.9 /cart 200 10.0.0.7 /cart 500 10.0.0.2 /home 200 10.0.0.7 /pay 200 10.0.0.9 /home 404 10.0.0.4 /home 200
prints
3 10.0.0.7 2 10.0.0.9 1 10.0.0.2
Constraints
- 3 to 30 lines, from at least 3 visitors
Write it in your browser, against the clock. The model script, with a note on each command it uses, comes after.
More Bash problems
- Lines of CodeHard
- Only in the FirstHard
- Share of ErrorsHard
- Shift Them UpHard
- Sort Into FoldersHard
- TODOs per FileHard
- The Biggest FileHard
- Totals per GroupHard