curena
1/19/2017 - 11:45 PM

How to check if a variable is not set in Bash

How to check if a variable is not set in Bash

if [ -z ${var+x} ]; then echo "var is unset"; else echo "var is set to '$var'"; fi