FunctionRacerProblemsRace

Share of Errors

HardBasha shell script

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

Race itor take your time

Write it in your browser, against the clock. The model script, with a note on each command it uses, comes after.

More Bash problems