Is there a simple Unix shell command to list dates backwards?
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 Saturday July 2 2005 Friday July 1 2005 Thursday June 30 2005 Wednesday June 29 2005 Command must transit months, years, leap-years, etc. Does gcal, or any other Unix command, have this capability? Thanks, Doug
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
I can't offer any help, but I am curious what you are doing. Thanks, Bob On Jul 5, 2005, at 5:23 PM, 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 Saturday July 2 2005 Friday July 1 2005 Thursday June 30 2005 Wednesday June 29 2005
Command must transit months, years, leap-years, etc.
Does gcal, or any other Unix command, have this capability?
Thanks, Doug
_______________________________________________ Wlug mailing list Wlug@mail.wlug.org http://mail.wlug.org/mailman/listinfo/wlug
participants (3)
-
douglas.r.aker@verizon.com
-
Robert Breznak
-
Theo Van Dinter