December 2018
Beginner
452 pages
12h 17m
English
We'll start this chapter off with a short recap on positional arguments. As you might remember from Chapter 8, Variables and User Input, we are able to use positional parameters to pass arguments to our scripts.
To put this simply, the following syntax is used:
bash script.sh argument1 argument2 ...
Inside the preceding (fictive) script.sh, we can then grab the values supplied by the user by looking at the positions the arguments are supplied in: $1 is the first argument, $2 is the second, and so on. Remember that $0 is a special argument, which relates to the name of the script: in this case, script.sh.
This approach is relatively simple, but also susceptible to errors. When you write this script, you ...