What Bash Is, and Why Script It
Every Friday you open a terminal, make a backups folder, pack your notes into an archive with today's date in the name, and list the folder to check it worked. It takes a minute, and sooner or later you mistype the date. Bash can type those lines for you, the same way every time.
The rule
If you typed it twice, a script can type it forever.
A shell is the program behind your terminal prompt. It reads the line you type, finds the program you named, runs it with the arguments you gave, and waits for the next line. Bash (the "Bourne Again SHell") is the most widely used shell: the default on most Linux systems, and present on macOS even though macOS now opens zsh by default. Others you will meet are sh/dash (small and strict), zsh and fish (friendly for typing), and PowerShell on Windows.
The command line (CLI) and a graphical interface (GUI) are good at different things. A GUI helps you discover: you see the options and point at things. A CLI helps you repeat and combine: a command is text, so it can be saved, copied, and run again on a thousand files.
A script is a plain text file of commands. Bash reads it from the top, one command at a time, exactly as if you were typing each line. Here are the Friday commands you would type by hand:
mkdir -p ~/backups
tar -czf ~/backups/notes-2026-09-25.tar.gz ~/notes
ls ~/backupsSaved in a file, these three lines are the first version of backup.sh, the script you will grow throughout this course.
The shortcut
Before scripting a task, run the "same way again?" test on each line: would I type this exactly the same next time? Lines that pass are ready to paste. Lines that fail contain a part that changes, and that part will become a variable later.
Spot the repetition
The same three commands run every week, in the same order. That is a script waiting to happen.
A common mistake is to script a task before you have done it by hand once. Type it first, watch it work, then save the lines that worked.
Drills
Answer fast — trust the rule.
What does a shell such as Bash do?
When does a script clearly beat clicking through a GUI?
How does Bash run the commands in a script file?
Which of the three backup commands fails the "same way again?" test?
Remember
- If you typed it twice, a script can type it forever.
- A script is saved typing: Bash runs it top to bottom, one command at a time.
- Run the "same way again?" test; the parts that change become variables.
