I want to do this in bash:
//C pseudo code
if(cond1 is true and (cond2 is true or cond3 is true))
do something
This is what is have
var1=abc
var2=
if echo "$var1" | grep -q 'abc' && ( echo "$var2" | grep 'def' || [ "x$var2" = "x" ] )
then
echo hello
fi
This still prints hello.
I really need to use the echo grep construct. What should I do?
It correctly prints
hellobecause[ "x$var2" = "x" ]is true whenvar2is the empty string.