I'm trying to compare 2 dates between current time and the timestamp on a file.
The date format is mmdd
Both return Apr 1 but when using if statement
line 11: Apr 1: command not found error is returned
#!/bin/sh
log="DateLog"
Current_Date=`date +%b%e`
Filepmdate=`ls -l /file.txt | awk '{print $6,$7}'`
printf "$Current_Date \n"
printf "$Filepmdate \n"
if ( "$Current_Date" = "$Filepmdate" ) ; then
echo "Dates are the same" > /$log
exit 0
else
echo "Dates are Not the same" > /$log
exit 0
fi
any ideas ?
---------- Post updated at 11:26 AM ---------- Previous update was at 11:22 AM ----------
ok saw my error should used square brackets [] instead of ()
log="DateLog"
Current_Date=`date +%b%e`
Filepmdate=`ls -l /message.txt | awk '{print $6,$7}'`
printf "$Current_Date \n"
printf "$Filepmdate \n"
if [ "$Current_Date" = "$Filepmdate" ] ; then
echo "Dates are the same" > /$log
exit 0
else
echo "Dates are Not the same" > /$log
exit 0
fi