Skip to content

Instantly share code, notes, and snippets.

@agirorn
Created July 6, 2017 09:32
Show Gist options
  • Save agirorn/5e92cb2f9d859959ba7ab3bd705a201c to your computer and use it in GitHub Desktop.
Save agirorn/5e92cb2f9d859959ba7ab3bd705a201c to your computer and use it in GitHub Desktop.
Bash: Check if variable is set.
#!/usr/bin/env bash
# Uncomment next line to test
# VARIABLE=10
if [ -z ${VARIABLE+x} ]; then
echo "Variable \$VARIABLE is not set"
else
echo "Variable \$VARIABLE is set and has the value of => $VARIABLE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment