Quantcast
Viewing latest article 16
Browse Latest Browse All 16

Answer by Raman Kathpalia for How to determine if a bash variable is empty?

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

Viewing latest article 16
Browse Latest Browse All 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>