Why it matters
Doing a task once by hand is fine. Doing it every day on ten servers is how mistakes happen. Cloud and DevOps adverts in Ghana regularly ask for Bash or Python scripting because automation is the heart of the job: backups, health checks, user setup and deployments should run the same way every time, without someone remembering each step.
Your first Bash script
A Bash script is a text file of commands. Here is one that backs up a folder with the date in the file name:
#!/usr/bin/env bash
set -euo pipefail
src="$HOME/records"
dest="$HOME/backups"
mkdir -p "$dest"
tar -czf "$dest/records-$(date +%F).tar.gz" "$src"
echo "Backup done"The first line says which program runs the script. set -euo pipefail makes the script stop on errors instead of carrying on silently. $(date +%F) inserts today's date. Save it as backup.sh, make it executable with chmod +x backup.sh and run it with ./backup.sh.
Making decisions and checking results
Scripts get useful when they check something and react: