Share of Errors
Each line of access.log is a visitor, a page and a status code: 10.0.0.7 /home 200. A status of 500 or more is a server error. Print the share of lines that are server errors as a whole percentage, rounded down: 2 of 7 lines is 28.
Example 1
access.log
a /home 200 b /cart 500 c /cart 503 d /home 200 e /pay 200 f /home 404 g /home 200
prints
28
Constraints
- 1 to 30 lines
Write it in your browser, against the clock. The model script, with a note on each command it uses, comes after.
More Bash problems
- Shift Them UpHard
- Sort Into FoldersHard
- TODOs per FileHard
- The Biggest FileHard
- Totals per GroupHard
- Word Count TableHard
- Count the LinesBeginner
- Count the WordsBeginner