Re: [Wlug] Is there a simple Unix shell command to list dates backwards?
Thanks Theo, this is exactly what I was looking for. I actually emailed Thomas Esken (GNU gcal developer), and the best gcal example he could come up was... gcal -f/dev/null -Hno -#0*d1#999 -c-Qxld20- %20070706 But this command works only up until the beginning of any calendar year, i.e. it doesn't easily cross year boundaries like your suggestion does. FYI: I need this sort of command in order to generate charts (using XML:SVG) that display metrics from some DB2 Connect gateways that I admin. The title of one chart might be: Total Daily Connections, last 100 days. If data for any day is missing, I want the chart to reflect that. Currently, the charts I'm creating handle missing days poorly, they simply cover up gaps in the data with the next previous day's metric. Thanks again, Doug p.s. SVG is interesting: http://www.w3.org/Graphics/SVG/ "Theo Van Dinter" <felicity@kluge.n To: "Worcester Linux Users Group" <wlug@mail.wlug.org> et> cc: Sent by: Subject: Re: [Wlug] Is there a simple Unix shell command to list dates backwards? wlug-bounces@mail .wlug.org 07/05/2005 05:43 PM Please respond to "Worcester Linux Users Group" On Tue, Jul 05, 2005 at 05:23:24PM -0400, douglas.r.aker@verizon.com wrote:
I'm looking for a standard Unix shell command that can list an arbitrary number of day dates backwards from today. For example, something like this:
$ unixcommand -7 Tuesday July 5 2005 Monday July 4 2005 Sunday July 3 2005 [...]
Command must transit months, years, leap-years, etc.
Nothing comes to mind, but I'd do something like: $ perl -e 'for($i=0;$i<=$ARGV[0];$i++){ print scalar(localtime(time-86400*$i)),"\n"; }' 7 Tue Jul 5 17:31:35 2005 Mon Jul 4 17:31:35 2005 Sun Jul 3 17:31:35 2005 [...] Or if you need that other specific format: #!/usr/bin/perl my @mon = qw/January February March April May June July August September October November December/; my @day = qw/Sunday Monday Tuesday Wednesday Thursday Friday Saturday/; my $time = time; my $count = $ARGV[0]; while($count--) { my @lt = localtime($time); print join(" ", $day[$lt[6]], $mon[$lt[4]], $lt[3], 1900+$lt[5]),"\n"; $time -= 86400; } $ perl script 7 Tuesday July 5 2005 Monday July 4 2005 Sunday July 3 2005 [...] -- Randomly Generated Tagline: "I love deadlines. I like the whooshing sound they make as they fly by." - Douglas Adams _______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug #### C.DTF has been removed from this note on July 06 2005 by Doug Aker
participants (1)
-
douglas.r.aker@verizon.com