Step 6 of 7 · lab · 20 min
Count the errors in the logs
A summary of the night's error codes from the shop logs: a pipeline into a file, the command's errors into another one, the history appended.
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 · on your own
No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.
Goals
0 of 3-
~/report/errors-by-code.txt lists the count and code of each error, most frequent first — not done yet
-
~/report/failed.txt holds only the command's error messages — not done yet
-
~/report/history.txt keeps the earlier lines and ends with a line for 2026-10-19 — not done yet
The machine is starting
Hints
0 of 3Lab goals
0 of 3-
~/report/errors-by-code.txt lists the count and code of each error, most frequent first — not done yet
-
~/report/failed.txt holds only the command's error messages — not done yet
-
~/report/history.txt keeps the earlier lines and ends with a line for 2026-10-19 — not done yet
Goals are checked on the machine after every command.