Validate and Calculate

Hi,
i am trying to validate 2 variables and then subtract, the following code works well in AiX but when i try in Solaris it doesnt work.

((TIME1>TIME2)) && ((TIME2=TIME2+864))
((DIF=TIME2-TIME1))
echo difference = $DIF Seconds

is there any way the validation can be done using expression or bc or any other method...

Thanks in advance

try this

[[ $TIME1 -gt $TIME2 ]] && ((TIME2+=864))
((DIF=TIME2-TIME1))
echo differenece = $DIF seconds

Are there any errors ?
try intermediate echo to see what's going wrong

Thanks a lot Frans :slight_smile:

i figured out another solution as below,

if [ $TIME1 -gt $TIME2 ];then
TIME2=`echo $TIME2+864| bc`
fi