
07-03-2008
|
|
Moderator
|
|
|
Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
|
|
Quote:
Originally Posted by nayanasavio
hi there,
date -d '1 week ago'
or
date -d '7 days ago'
will give the date and time of exactly a week ago.
You can use '1 month ago' 'yesterday', '2 hours ago', etc..
For future dates, use 'tomorrow', '2 hours now', '1 week now', etc
Any date before/after any time period can be displayed this way.
Month=$(date -d '1 week ago' +%m)
Day=$(date -d '1 week ago' +%d)
Year=$(date -d '1 week ago' +%y)
echo $Month "/" $Day "/" $Year 
|
this is GNU-ism and is not guaranteed to be installed.
|