Situation
Last night an online shop kept answering its customers with errors. Its logs live in
/var/log/shop, one file per part of the site. In the morning a colleague asks for a summary:
which error codes there were and how many times each. "If you can't read one of the logs,
that's fine — just keep the message about it separately, and I'll sort out the access."
The colleague keeps the summaries of earlier nights in ~/report/history.txt, one line per
night.
Task
Make it so that:
~/report/errors-by-code.txthas, for each code found inERRORlines, the number of such lines and the code itself — one line per code, separated by a space, the most frequent first;~/report/failed.txtholds the error messages of the command that read the logs, and nothing else;- a line for this night appears at the end of
~/report/history.txt, in the same form as the earlier ones:2026-10-19and the total number ofERRORlines. The earlier lines must stay where they are.
Read the logs as yourself, without sudo: the summary covers what is open to you.
Lab goals
0 of 3-
~/report/errors-by-code.txt lists the count and code of each error, most frequent first — not checked yet
-
~/report/failed.txt holds only the command's error messages — not checked yet
-
~/report/history.txt keeps the earlier lines and ends with a line for 2026-10-19 — not checked yet
Hints
0 of 3 open · they open one at a time
Hint 1
Show the solution
after 3 failed checks