To check if a variable is set or empty, we can use couple of approaches. One approach is to use empty string check (if [ -z $string]) . This approach is little inaccurate but will work in most cases. Better approach is to use parameter substitution (${var+val}) and then empty string check (if [ -z $string]).