Skip to content
$ lynuxpro
← All projects

BASH SCRIPTING PROJECT · ABOUT 40 MIN · +150 XP

Log analyser script

Support keeps asking 'how bad is the app log today?'. Write a script they can run themselves.

Your tasks

  1. Create ~/bin/logstat.sh starting with #!/bin/bash and set -euo pipefail.
  2. If it's run without an argument, print Usage: logstat.sh FILE and exit with code 2.
  3. If the file doesn't exist, print No such file: followed by the name and exit with code 1.
  4. Otherwise print two lines: Total: N (number of lines) and Errors: M (lines containing ERROR).
  5. Make it executable and try it on /var/log/app/app.log.

Stuck? Every step is covered in the Bash Scripting lessons.

Sign in to start this project

Your progress is checked and saved to your profile.

Sign in