Bash Scripting
Bash scripts automate repetitive tasks on Linux. A script is a text file with commands, starting with the shebang line.
Hello Script
#!/bin/bash
# myscript.sh
echo "Hello, world!"
echo "Today: $(date)"
Make it executable: chmod +x myscript.sh — then run ./myscript.sh.
Variables and Loops
name="Hanse"
for f in *.log; do
echo "Processing $f"
done
Good Practices
Use set -e to stop on errors, quote variables ("$var"), and test with bash -n script.sh to check syntax.
Related: Linux Basics · systemd Explained