In Bash you quite often need to check to see if a variable has been set or has a value other than an empty string. This can be done using the
-z string comparison operators.
-n operator checks whether the string is not null. Effectively, this will return true for every case except where the string contains no characters. ie:
if [ -n "$VAR" ]; then
echo "VAR is not empty"
-z operator checks whether the string is null. ie:
if [ -z "$VAR" ]; then
echo "VAR is empty"
Note the spaces around the square brackets. Bash will complain if the spaces are not there.