Setting a variable in bash if it is not defined
Update: An anonymous commenter pointed out that bash has the ability to do this in a much shorter way:
BLAH=${BLAH:-no}
Job done!, my original older way is below…
[root@sn-b02 init.d]# echo $BLAH
[root@sn-b02 init.d]# [ "${BLAH}" = "" ] && export BLAH="no"
[root@sn-b02 init.d]# echo $BLAH
no
[root@sn-b02 init.d]#
Subscribe via RSS