[lug] Creating date variables in bash

Bill Thoen bthoen at gisnet.com
Tue Oct 12 11:09:04 MDT 2004


On Tue, 12 Oct 2004, Shannon Johnston wrote:

> I did it with this:
> 
> DATE=`date '+%Y-%m-%d'`
> YESTERDAY=`date +%Y-%m-%d -d "-1 day"`

Ah. So it was in the man pages after all. Another question then. Where do
they describe the allowed formats of STRING in 'date --date=STRING'?



> 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.
> > 
> > - Bill Thoen
> > 
> > 
> > _______________________________________________
> > Web Page:  http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> > Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> 




More information about the LUG mailing list