This is a discussion on Re: Date arithmetic on Unix - Hewlett Packard ; On Wed, 5 Mar 2008 15:03:00 -0000, Robert Mills wrote: >Greetings to the -L, > >I know that this is not an MPE question but I gather that there are >loads of e3000 sites out there that also have 9000's ...
On Wed, 5 Mar 2008 15:03:00 -0000, Robert Mills
>Greetings to the -L,
>I know that this is not an MPE question but I gather that there are
>loads of e3000 sites out there that also have 9000's and other Unix
>I have been asked to take an existing Korn (ksh) script and remove the
>need to manually edit some dates in it (today - 1 month, today - 1 day,
>today + 1 day, today + 1 month, etc) by getting the shell to calculate
>All the methods I have currently found required a date command which
>recognises the -d switch. Unfortunately our doesn't.
>If I am unable to get the shell to do it then I'll have to write a small
>program in C or C++ which will open a can of worms with the supplier of
>Any suggestions (clean ones please) will be gratefully received.
It's not shell, but if you happen to have Python 2.3 or later on the system,
it has built-in date arithmetic:
#! /usr/bin/env python
print datetime.date.today() - datetime.timedelta(days=30)
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *