String Comparison Issues

Hello there. I am trying to write a simple script that pulls the date on which the system was last shutdown (stored in a file called 'last_shutdown') and today's date (the days only) and compares the two. If the two match, I want it to perform some tasks.

That is, if today is 31 May 2010 and the last shutdown was also 31 May 2010, I want it to compare only the days ('31' and '31'). Only the days are enough because the script is in my crontab and runs everyday.

This is what I have done.

last_shutdown=`cat ~/bin/last_shutdown` #The file last shut_down consists of '31'

today=`date +%d` #Let us assume that this gives us '31' as well

if [ $today=$last_shutdown ];
then
  #Perform some functions
  echo "THIS PROVES THAT THE COMPARISON WORKS"
fi

However, even when last_shutdown and today do not match, the functions inside the if structure run.

What am I doing wrong?

should be

if [ $today = $last_shutdown ];
then
  #Perform some functions
  echo "THIS PROVES THAT THE COMPARISON WORKS"
fi

note the space around "=" sign.

-dips

Use :

[ "$today" = "$last_shutdown" ];