[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: script with date operation??



On Sat, May 13, 2006 at 02:59:04PM -0300, Bruno Buys wrote:
> Is there any nice tool to operate dates at the console?
> thanks!

It's perhaps a bit too heavy, but I always use Perl's
DateManip for that:
http://search.cpan.org/~sbeck/DateManip-5.44/Manip.pod

I had to write a script a while back that computed "one week
before today"; DateManip's way of writing that is quite
literate and quite easy to code:

LASTINTERVAL=`perl -e "use Date::Manip; print UnixDate(DateCalc(\"now\",\"-1 week\"), \"%d/%b/%Y\")"`

In general, I should note that "perl -e" is super-awesome.

The alternative, using just the command-line 'date' tool, is
too cumbersome. Perl's actually the easiest here, I've
found.

-- 
Stephen R. Laniel
steve@laniels.org
Cell: +(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key

Attachment: signature.asc
Description: Digital signature


Reply to: