[lug] Creating date variables in bash
thompsma at colorado.edu
Tue Oct 12 11:12:55 MDT 2004
On Tue, 2004-10-12 at 10:47, Bill Thoen wrote:
> I can get today's date into a bash variable like so:
> D=$(date +%G%m%d)
> but how do I get the date for say, 7 days ago?
> I tried 'man date' but didn't see an option for doing date math.
> date -d "7 days ago"
Tue Oct 5 11:11:23 MDT 2004
Add your format string after it. One of those useless things I learned
a long time ago..."1 week ago" works too. You start playing around with
-d way too much after learning about it.
Learning just means you were wrong and they were right. - Aram
Matt Thompson -- http://ucsub.colorado.edu/~thompsma/
440 UCB, Boulder, CO 80309-0440
JILA A510, 303-492-4662
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: This is a digitally signed message part
More information about the LUG