View Single Post

   
  #7 (permalink)  
Old 05-12-2008, 09:08 AM
William Hunt
 
Posts: n/a
Default Re: OT: util for relative date?

On Sun, 11 May 2008, Bartosz Oudekerk wrote:
> William Hunt <wjh@prv8.net> typed on 2008-05-11:
>> i'm looking for a util which, given an integer argument N,
>> can print the date of the day N days ago.

>
> #!/bin/bash
> date -d "${1} days" +%Y/%m/%d
>


But, note that if $1 is null, we get tomorrow's
date ... but ${1:-0} works in all cases.

( I rotate and archive logfiles by day, /var/log/YYYY/DD/MM/... ,
and this might make it easier now to get at yesterday's logs,
/var/log/$(day -1)/... )


hanks, Bartosz.


--
William Hunt, Portland Oregon USA
Reply With Quote