Ad space (banner)
Lesson 20 / 20

[Project] Build a small log-tallying script

In this lesson you combine the arrays, functions, grep, and arithmetic covered so far into a simple log-tallying script. It is the capstone of this shell scripting introduction.

Operations teams write scripts like this constantly: total the entries at each log level (INFO, WARN, ERROR) and raise an alert when there are too many problems.

The sample code sets up an array of log levels, counts each one with grep -c, and prints the results as a report.

Variables, arrays, branching, and text-processing commands — everything covered in these lessons — are the foundations of real server operations and automation work. Starting with small scripts and gradually taking on more complex automation is the shortest path to using shell scripting professionally.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Shell Script directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)