*BSD News Article 34817


Return to BSD News archive

Xref: sserve comp.unix.bsd:14671 comp.unix.misc:13603 comp.unix.programmer:19460 comp.unix.questions:54029
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!news.Hawaii.Edu!ames!hookup!usc!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!swidir.switch.ch!newsfeed.ACO.net!Austria.EU.net!EU.net!uunet!news1.digex.net!digex.net!not-for-mail
From: saalwaec@access1.digex.net (John W. Saalwaechter)
Newsgroups: comp.unix.bsd,comp.unix.misc,comp.unix.programmer,comp.unix.questions
Subject: Re: Q:  How can I get yesterday's date?
Date: 16 Aug 1994 09:09:42 -0400
Organization: Express Access Online Communications, Greenbelt, MD USA
Lines: 30
Message-ID: <32qdqm$bnv@access1.digex.net>
References: <Pine.3.89.9408160216.A15886-0100000@worf.uwsp.edu> <32q00b$9vn@daphne.ecmwf.co.uk>
NNTP-Posting-Host: access1.digex.net

In article <Pine.3.89.9408160216.A15886-0100000@worf.uwsp.edu>, pzuge@worf.uwsp.edu (Peter Zuge) writes:
> I am using BSD/386 unix:
> 
> I need to create a script that will run at a certain time everyday 
> "getting" ( via ftp ) a file with yesterday's date.

[stuff about getting yesterday's date deleted.]

% uname -rsv
BSD/386 1.0 0
% date
Tue Aug 16 08:56:09 EDT 1994
% date -r `perl -e 'print time - 24*60*60'`
Mon Aug 15 08:56:15 EDT 1994
%

Combine the '-r' option to date with perl's 'time' capability to get yesterday's date.
For your specific question (using the Bourne shell):

$ yestertime=`perl -e 'print time - 24*60*60'`
$ yy=`date -r $yestertime +%y`
$ mm=`date -r $yestertime +%m`
$ dd=`date -r $yestertime +%d`
$ fn="GS$yy$mm$dd.LOG"

-- 
/************************************************************/
/* John Saalwaechter                                        */
/* saalwaec@access.digex.net                                */
/************************************************************/