How to check if a Bash variable is empty

if [ -z "$VARIABLE" ]

If $VARIABLE is not set or empty the if statement above will return true, the -z option tests for a zero-length string, so whether $VARIABLE is not set or empty the ifstatement will return true

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.