To figure out if a variable "Foo" is empty and also contains no spaces (or no whitespace as some people refer it).
if [[ -n "${Foo/[ ]*\n/}" ]];then echo "Foo is not empty and contains non space characters"fi# Another way to solve the same problem: Take spaces out in Foo & check if Foo is empty if [[ -z "${Foo// }" ]];then echo "Foo is empty" fi