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

Image Credits: Photo by Isis França on Unsplash.

More Similar Posts

No results found.

Menu