Whats wrong with this IF condition?

I have four variables, dumpdata, defndata, compare1 and compare2

I want an IF statement condition which returns true when either dumpdata=defndata or (dumpdata<=compare1 and dumpdata>=compare2).

But this is not working for me..

if [ $dumpdata=$defndata || (( $dumpdata <= $compare1 ) && ( $dumpdata >= $compare2 )) ]

It would help if you mention which shell you are using.

Usually you need to use [[ ]] if you want to use || and &&. Also you may need to use -le instead of <= and -ge instead of >=.

I am using ksh.

Do you mean to use this:

if [[ ($dumpdata -eq $defndata) || (($dumpdata -le $compare1) && ($dumpdata -ge $compare2)) ]]

Looks good to me... does it work?

Another good habit is to enclose variables in test statements like this between "quotes". That way if one of the variables happens to be empty the statement logic will still work instead of your script terminating with an 'invalid syntax' error.

yes it works!

And thanks for the tip.