Example : A Backup Script

#!/bin/sh

# this requests date to return day of the week as a number w sunday = 0
d=(`date "+%w"`)
#d=0

# not necessary, but cool
# week=([Mon]=0 [Tue]=1 [Wed]=2 [Thur])

#Sunday is 0, saturday is 6
DOW=(sunday monday tuesday wednesday thursday friday saturday)

# remove existing files for the day
/bin/rm /backup/${DOW[$d]}/*dbf.Z

#date 2 compress is today - 2
d2c=$(( $d - 2 ))

#But if today is Sunday or Monday, scroll up to saturday or friday
if [ $d2c -lt 0 ] then
d2c=$(( 7 + $d2c ))
fi

/bin/compress /backup/${DOW[$d2c]}/*.dbf