Get the date of monday when running from Friday to next Thursday

Hi,
I have a requirement where I want to get the date of monday when I am running the script from previous Friday to the following Thursday.

For example: When ever I run the script between 19thFeb2010(Friday) to 25th Feb 2010(Thursday), I should get the date of 22nd Feb 2010 in the format of 'mm/dd/yyyy'.

Can any one please help me out.

Thank in advance.

I understood your requirement.I want to know whether you give the from and to date as input or not.If you give it as input,then explain me in which format you give those dates.

what do u expect if the To date is 4thmarch2010 ( Thursday ) ,

I am giving the system date in the format 'mmddyy'.
If we are running the script on 4th March 2010, it should give as '03/01/10'

Are you expecting this,

cur=`date +"%u"`
if [ $cur -eq 1 ]
        then
        echo `date "+%m/%d/%Y" `
        elif [[ $cur -gt 4 || $cur -eq 0 ]]
        then
         case $cur in
                 0) echo `date "+%m/%d/%Y" -d "+1 day"`;;
                 5) echo `date "+%m/%d/%Y" -d "+3 day"`;;
                 6)echo `date "+%m/%d/%Y" -d "+2 day"`;;
         esac
        else
         case $cur in
                 2) echo `date "+%m/%d/%Y" -d "-1 day"`;;
                 3) echo `date "+%m/%d/%Y" -d "-2 day"`;;
                 4) echo `date "+%m/%d/%Y" -d "-3 day"`;;
         esac


        fi

Hi Karthigeyan, Thanks for your reply.
But "date -d" option is not working in my server. It is saying '-d' as not a recognized flag. I am using AIX.
Can you guide me if there is any other way?