How do I assign a variable only if another variable is set in a bash shell script?
-
Using the syntax ${name+word}
Here URL is set so WEBURL variable will have the value www.gnu.org
URL=yes WEBSITE_URL=${URL+"www.gnu.org"} echo $WEBSITE_URL
$ ./varsubs.sh www.gnu.org
© Lightnetics 2024