- What is parameter substitution?
Nothing more than the run-time substitution of the variable name with its value at that moment.
- How can we include default values for our defined variables?
With the ${variable:-value} syntax, where variable is the name and value the default value. This will only be used if the value is null or empty ('').
- How can we use parameter expansion to handle missing parameter values?
While you would normally use an if [[ -z ${variable} ]]; then, parameter expansion allows you to use the following syntax to generate an error message and exit 1: ${1:?Name not supplied!}
- What does ${#*} do?
It is the same as $#, which we use to determine the number of arguments passed to our shell script. The general ${#name} syntax allows us to get the length of the value of the name variable.
- How does pattern substitution work when talking about parameter expansions?
Pattern substitution allows us to take the value of a variable and modify it slightly, by doing a search/replace for a pattern.
- How is pattern removal related to pattern substitution?
Removing a pattern is the same as replacing a pattern with nothing. With pattern removal, we get the added flexibility of search both from the beginning of the text (prefix) and from the end (suffix). Pattern removal is great when working with file paths.
- What types of case modifications can we perform?
- Lowercasing
- Upercasing
- Reversing the casing
- Which two things can we use to get a substring from a variables' value?
We need an offset, or a lenght, orĀ the combination of both (most common).