Sunday, 15 June 2014

Shell Script logical operator for conditions -



Shell Script logical operator for conditions -

$i="500,600" $j="600" if[$i -ne $j]; #some line else #some line fi

this if status not going inside.

this if status fails. else pass.

how possible

can help me on this

the trick consider "[" sign command (in fact 1 indeed), lastly argument must "]". must ensure there space after [ , of arguments go proper place. in case:

if [ "$i" -ne "$j" ] # code else # code fi

since [ command, might want omit if construction , utilize logical operators, taking advantage of lazy evaluation. next means same:

[ "$i" -ne "$j" ] && { echo "hello" ; echo "world" ; } || { echo "bye bye" ; echo "world" ; }

shell

No comments:

Post a Comment