I have a script and in this I want to be able to take a date and work on the dates of the seven days before this date.
If the date is today then I can use the date command like this:
but how can I best do it for any other date?
Thanks for any help
Emma
--------------------------------------
For animals, the entire universe has been neatly divided into things to (a) mate with, (b) eat, (c) run away from, and (d) rocks.
-- Terry Pratchett, Equal Rites
If the date is today then I can use the date command like this:
Code:
x=7
while [ $x -ge 0 ]
do
DAY="$( date --date="${x} days ago" +%D)"
## work with the date I've found
x=$(($x-1))
done
but how can I best do it for any other date?
Thanks for any help
Emma
--------------------------------------
For animals, the entire universe has been neatly divided into things to (a) mate with, (b) eat, (c) run away from, and (d) rocks.
-- Terry Pratchett, Equal Rites