small date problem

Hi there I currently use a line in a script

ndate=$(date +"%d/%m/%Y")

This obviously returns the date in a format i have chosen. However, I need to come up with a solution for weekends and as such need a way of returning todays date minus two days in the same format (24/11/2004)

so for example if today was monday and the command ndate=$(date +"%d/%m/%Y") returned 17/01/2005, I would want to redo that command so that it would return 15/01/2005 (saturdays date)

any ideas

If you don't have GNU date, have a look at Perderabo's excellent datecalc script.

If you do have GNU date, then just do
ndate=$(date -d "2 days ago" +"%d/%m/%Y")

Cheers
ZB

my date doesnt have the-d option so i presume it is not the gnu version....I have solaris 8, do you know if there is a gnu date for this platform ??

If you have GCC or another suitable compiler on your system you can head over to GNU.org and pick up coreutils - compile from source then not only will you get date but also a plethora of other tools and utilities.

If not, try sunfreeware as they have coreutils as a package for SPARC and Intel architectures.

Cheers
ZB