mercredi 1 février 2017

Variable values are becoming null in the IF statement

I am trying to do a simple comparison using IF construct in bash scripting. Here is my code:

if [ ${ca} -eq ${cb} ] 
then
    echo "Compaction successful"
else
    echo "Compaction Unsuccessful"
fi  

The problem is when I put 'set -x' in the script, I notice that the above code shows up like this:

+ [[ '' == '' ]]
+ echo 'Compaction successful'
Compaction successful

Why are my variables not being substituted in the IF statement although there is data(number) in them?

Aucun commentaire:

Enregistrer un commentaire