Linux Command Line · 14-day planAll days
Day 11 of 14 35 minShebangArgumentsif
Save commands in a file and run them as a program. Write scripts with a shebang, make them executable, take arguments, make decisions with if and test, read input, return exit codes, and use the safety settings experienced people put at the top of every script.
By the end of today you can
- Write, make executable and run a bash script
- Use arguments $1, $#, $@ and default values
- Make decisions with if, test brackets and case
- Return meaningful exit codes and react to other commands' exit codes
- Make scripts safer with set -euo pipefail and quoting
What's inside
- 6 sections
- 2 diagrams and mind maps
- 7 code examples you can run
- 5-question quiz
- 1Your first script
- 2Arguments
- 3Making decisions: if and test
- 4Exit codes
- 5Reading input
- 6Writing safer scripts
Sign in free to read this lesson
Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.
Sign in free