From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,37d7a16bb2db2c0b X-Google-Attributes: gidfee84,public From: weber@NOSPAM.bucknell.edu (Chris Weber) Subject: Re: Date Calculations Date: 1998/10/09 Message-ID: #1/1 X-Deja-AN: 399331413 Sender: weber@megmodem.bucknell.edu References: <6v2mt1$74e$1@nnrp1.dejanews.com> <6vju3c$emk$1@newsflash.concordia.ca> Organization: Bucknell University Newsgroups: comp.unix.osf.osf1 In article <6vju3c$emk$1@newsflash.concordia.ca>, smw@trm.concordia.ca ( Steven Winikoff ) wrote: >In <6v2mt1$74e$1@nnrp1.dejanews.com> lloydy1090@my-dejanews.com writes: > >>I want to be able to set a variable to the current date minus 7. I'm using >>date +"%d-%b-%y"to return the current date and I want to be able to return >>the same format for 1 week ago. > >I don't have *exactly* what you're looking for, but I have two >suggestions that come fairly close. > >First of all, there's a program called "calcdate" in Volume 3, Issue 22 >of comp.sources.misc. AltaVista reports a copy at > > http://ftp.doc.ic.ac.uk/packages/unix-c/calendars/calcdate.c.gz GNU _date_ can do this via its "-d" flag, used to tell _date_ what time to pretend it is. The syntax accepted by "-d" is quite flexible. To have GNU _date_ return what you require, you could incant: $ date -d "-7days" +%d-%b-%y GNU _date_ is part of the GNU Shell Utilities package, which can be found at: ftp://ftp.gnu.org/pub/gnu/sh-utils-1.16.tar.gz -- Chris Weber Bucknell Computer and Communication Services