Skip to main content
added 35 characters in body
Source Link

You will run into issuesTo figure out if a variable - "Foo" is empty and also contains no spaces (or no whitespace as some people refer it). To solve that, use:

 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

You will run into issues if a variable - "Foo" contains spaces. To solve that, use:

 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

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
Fixed grammar for easy understanding
Source Link

You will run into issues if thea variable - "Foo" contains spaces. To solve that, use:

 if [[ -n "${variableFoo/[ ]*\n/}" ]];then

    echo "variable"Foo is not empty and contains non space characters"

fi


# Another way to solve the same problem: Take spaces out in $variableFoo & check if $variableFoo ==is NULLempty

 if [[ -z "${variableFoo// }" ]];then

     echo "variable"Foo is empty"

 fi

You will run into issues if the variable contains spaces. To solve that, use:

 if [[ -n "${variable/[ ]*\n/}" ]];then

    echo "variable is not empty and contains non space characters"

fi


# Another way to solve the same problem: Take spaces out in $variable & check if $variable == NULL

 if [[ -z "${variable// }" ]];then

     echo "variable is empty"

 fi

You will run into issues if a variable - "Foo" contains spaces. To solve that, use:

 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
deleted 64 characters in body
Source Link

You will run into issues if the variable contains spaces. To solve that, use:

 if [[ -n "${variable_namevariable/[ ]*\n/}" ]];then         

    echo "variable is Notnot empty and contains non space characters"

fi


# Another way to solve the same problem: Take spaces out in $variable_name$variable & check if $variable_name$variable == NULL

 if [[ -z "${variable_namevariable// }" ]];then                    

     echo "variable is empty"

 fi

You will run into issues if the variable contains spaces. To solve that, use:

if [[ -n "${variable_name/[ ]*\n/}" ]];then         

    echo "variable is Not empty and contains non space characters"

fi


# Another way to solve the same problem: Take spaces out in $variable_name & check if $variable_name == NULL

 if [[ -z "${variable_name// }" ]];then                    

     echo "variable is empty"

 fi

You will run into issues if the variable contains spaces. To solve that, use:

 if [[ -n "${variable/[ ]*\n/}" ]];then

    echo "variable is not empty and contains non space characters"

fi


# Another way to solve the same problem: Take spaces out in $variable & check if $variable == NULL

 if [[ -z "${variable// }" ]];then

     echo "variable is empty"

 fi
added 5 characters in body
Source Link
Loading
added 5 characters in body
Source Link
Loading
added 48 characters in body
Source Link
Loading
Source Link
Loading