bash: Variable substitution - Use variable value if not-null otherwise use word.
-
Take into account the main readme for this section. README first.
Syntax is:
${name:-word}if the $name variable is not-null, then substitute its value, otherwise use word
Here Brazil is set, has a value of SugarCane
$ Brazil=SugarCane $ Amazon=${Brazil:-NoDeforestation} $ echo $Amazon SugarCane
Now make the variable Brazil null, and try again.
$ Brazil="" $ Amazon=${Brazil:-NoDeforestation} $ echo $Amazon NoDeforestation
© Lightnetics 2024