HP-UX IF Statement

Hi! I need help with my HP-UX Script. Its been written using Korn Shell. I'm trying to compare the system date, with the first date from a text file. And IF the dates match, it gives me a "Correct". Otherwise it states "Wrong". But it doesn't seem to be working. Please advise. Script and the output result that I see is below. I made a comparison between two dates whereby both dates are of the same date, and the output result should be "Correct". But the error points to my IF statement, and I can't figure out what's wrong. Your help is much appreciated.

#!/usr/bin/ksh
 
datentime=`(date '+%Y%m%d')`
newdate=$datentime
 
phdate= head -1 /usr/users/amsbmi/tmp/ph.txt
dd=$phdate
 
if [[$newdate -eq $dd]];
then
echo "Correct";
else
echo "Wrong";
fi

__________________________________________________________________________

Output Received:

20100112
./remplc.sh[9]: [[20100112:  not found
Wrong
ben1211Asked:
Who is Participating?
 
woolmilkporcConnect With a Mentor Commented:
#!/usr/bin/ksh
 
datentime=$(date '+%Y%m%d')
newdate=$datentime
 
phdate=$(head -1 /usr/users/amsbmi/tmp/ph.txt)
dd=$phdate
 
if [[ $newdate -eq $dd ]];
then
echo "Correct"
else
echo "Wrong"
fi
Besides the things I marked bold, please note the spaces around "[[ " and " ]]"
wmp


0
 
ben1211Author Commented:
Thanks wmp....it works :)
0
All Courses

From novice to tech pro — start learning today.