How do I assign a value to a variable if there is no default value in a bash shell script?
-
Also see: How do I assign a value to variable when a variable has no default value?
The above article does not set the URL variable if empty.
Using the syntax ${name=word}
This does:
WEBSITE_URL=${URL="www.gnu.org"} echo $WEBSITE_URL echo $URL
The result is both variables will be set.
$ ./varsubs.sh # www.gnu.org www.gnu.org
© Lightnetics 2024