How do I assign a value to variable when a different variable has no default value in a bash shell script?



  • Here the variable URL is not set so, WEBSITE_URL becomes www.gnu.org

    Using the syntax ${name-word}

    WEBSITE_URL=${URL-"www.gnu.org"}
    echo $WEBSITE_URL
    

    Running the script give the following results:

    $ ./varsubs.sh
    www.gnu.org
    

Log in to reply
 

© Lightnetics 2024