Setting default value for a BASH variable

From Setting default value for a BASH variable

To set a default value for a BASH variable (good for setting default value for a BASH command line parameter) the syntax is:

#Set VARIABLE with the value of 1st Arg to the script,
#If 1st arg is not entered, set it to DEFAULTVALUE
VARIABLE=${1:-DEFAULTVALUE}

Leave a Reply

Your email address will not be published. Required fields are marked *