Updates:

Similar topics mod installed, currently shown at the end of a topic

A "grep" problem

Started by Keith, May 25, 2018, 03:40:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Keith

Consider:

[email protected]:~$ q=$(ls | grep dEsktop)     (i.e. a non-existent file)
[email protected]:~$ echo $q

[email protected]:~$

I want to test the value of "q" for its null value here.  It's not " " or "", so what might it be? 
Can anyone help?


Keith

Found it at: https://serverfault.com/questions/7503/how-to-determine-if-a-bash-variable-is-empty

For a variable q:
               if [ -z "$q" ]; then ...... 
will detect if the variable is unset or the empty string "".