I'm trying to debug an existing program and found an if condition without $ symbol prefixed to it.
If condition goes like:
if [ dt_val -eq prev_dt_val ] then echo "Equal" else echo "Not equal" fi Result: Equal
Anyone throw some light on how the condition is working fine without a $ symbol?
Shouldn't that be..?
[ $dt_val -eq $prev_dt_val ]
The same condition fails when comparing string values. Does that mean, this condition does not require a $ symbol for number?
Comparing Strings with == as suggested:
dt_val="abcd" prev_dt_val="abcd" if [ dt_val == prev_dt_val ] > then > echo Equal > else > echo Not equal > fi Not equal
echo $SHELL /usr/bin/ksh Version M-11/16/88f
Wondering why there's no error either.