Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thejandroman/ee76354b940a4c9908ff540fa54cb340 to your computer and use it in GitHub Desktop.
Save thejandroman/ee76354b940a4c9908ff540fa54cb340 to your computer and use it in GitHub Desktop.
bash-3.2$ echo $VAR
bash-3.2$ if [ -z $VAR ]; then echo ‘variable is unset’; fi
‘variable is unset’
bash-3.2$ if [ ! -z $VAR ]; then echo ‘variable is set’; fi
bash-3.2$ VAR=''
bash-3.2$ if [ -z $VAR ]; then echo ‘variable is unset’; fi
‘variable is unset’
bash-3.2$ if [ ! -z $VAR ]; then echo ‘variable is set’; fi
bash-3.2$ VAR='test'
bash-3.2$ if [ -z $VAR ]; then echo ‘variable is unset’; fi
bash-3.2$ if [ ! -z $VAR ]; then echo ‘variable is set’; fi
‘variable is set’
bash-3.2$ unset VAR
bash-3.2$ if [ -z $VAR ]; then echo ‘variable is unset’; fi
‘variable is unset’
bash-3.2$ if [ ! -z $VAR ]; then echo ‘variable is set’; fi
bash-3.2$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment