條款我想這樣做在bash:結合條件,如果在bash
//C pseudo code
if(cond1 is true and (cond2 is true or cond3 is true))
do something
這是什麼,是有
var1=abc
var2=
if echo "$var1" | grep -q 'abc' && (echo "$var2" | grep 'def' || [ "x$var2" = "x" ])
then
echo hello
fi
這仍然打印打招呼。
我真的需要使用echo grep構造。我該怎麼辦?
(儘管如此,您可能希望將'-q'添加到第二個'grep'。) – Arkku 2012-02-04 19:44:14