๐Ÿ“Š We use cookies & analytics to improve your experience. Learn more
Latest

Cloud, Linux & DevOps Basics Module 1 ยท Lesson 3 of 15

0% Exit to course

Module 1 ยท The terminal, without fear Lesson 3 of 15

Shell scripts that save you time

Learning objective

A shell script is a list of commands in a file, plus enough logic to make it worth saving. Variables, an if and a loop are 90% of every script you will ever write for a job.

Worked example

A ten-line script that prints disk usage, deletes log files older than seven days and writes one line to a summary file replaces fifteen minutes of manual work every Monday.

Your practice task

Write one script that takes a folder name as an argument, counts the files in it and prints a warning if the count is zero.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

A shell script is a list of commands in a file, plus enough logic to make it worth saving. Variables, an if and a loop are 90% of every script you will ever write for a job.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task โ€” do them and the final project brief writes itself.