Linux & the Command Line / Servers and scripts
Lesson 27 of 30
Bash scripts
A bash script is a list of commands in a file. Start it with #!/usr/bin/env bash, make it executable, and run it.
Key points
- #!/usr/bin/env bash on line one
- set -euo pipefail stops on errors
- chmod +x script.sh
#!/usr/bin/env bash
set -euo pipefail
for f in *.log; do
echo "$f: $(wc -l < "$f") lines"
doneQuiz · +10 XP
What is the first line of a bash script called?
Log in to save progress and earn XP.