I know, this question has been asked several times here but due to some reason whatsoever none of the answer mentioned before, didn't seem to work for me.
How can I check if the variable is not empty in bash, I tried the following methods but none of them worked:
if [ -z ${VAR+x} ]; then
echo "VAR is not set"
exit 1
fi
if [ -z ${VAR+set} ]; then
echo "VAR is not set"
exit 1
fi
if [ -z ${VAR} ]; then
echo "VAR is not set"
exit 1
fi
if [ -z ${VAR// } ]; then
echo "VAR is not set"
exit 1
fi
Any help will be appreciated.