Bash tips and tricks
Is variable empty or unset?
if [ -z "${MY_VAR}" ]; then
echo "It's empty or unset"
fi
Default values
${MY_VAR-default} # If MY_VAR is defined, use it; otherwise default
For variations on the theme, see e.g. Bash FAQ.
if [ -z "${MY_VAR}" ]; then
echo "It's empty or unset"
fi
${MY_VAR-default} # If MY_VAR is defined, use it; otherwise default
For variations on the theme, see e.g. Bash FAQ.