Set a default BASH variable if not defined
Use :-
#!/bin/sh
MY_VAR=${MY_VAL:-foo}
echo $MY_VAR
$ bash test.sh foo $ export MY_VAL=bar $ bash test.sh bar
Use :-
#!/bin/sh
MY_VAR=${MY_VAL:-foo}
echo $MY_VAR
$ bash test.sh foo $ export MY_VAL=bar $ bash test.sh bar
BashDefaultVariableIfNotDefined (last edited 2010-05-11 09:17:33 by DavidKeen)