"yesterdate" function? (and tomorrowdate too)

R McBurnett rdm2 at nvuxr.UUCP
Fri Jan 13 04:28:26 AEST 1989


In article <353 at bilver.UUCP> bill at bilver.UUCP (bill vermillion) writes:
>In article <19100001 at hpficad.HP.COM> mcr at hpficad.HP.COM (Matt Reprogle) writes:
>>
>>I need a way to get yesterday's date in YYMMDD format in a Unix script and put
>>it in a file.   I don't want to write a C program implementing an entire
>>calendar to do it. 
>>
>>Can anyone help?  
>>
>>Matt Reprogle
>>
>>{everywhere}!hplabs!hpfcla!mcr

try this

	$ date
	Thu Jan 12 13:21:36 EST 1989
	$ TZ=EST29EDT date
	Wed Jan 11 13:21:42 EST 1989

putting in your normal TZ parameter (5 for east coast) +24 goes back 24
hours.

Yes this works for tomorrow too

	$ TZ=EST-19EDT date
	Fri Jan 13 13:22:44 EST 1989

you can use the date command to get the YYMMDD also

	$ date "+%y%m%d"
	890112

and in combination with the TZ stuff.

-- 
Roe D McBurnett III	Bellcore		|these are my own
(201)758-2333	 rdm2 at nvuxr.cc.bellcore.com	|rantings not Bellcore's



More information about the Comp.unix.questions mailing list