Subject: Re: Re: date feature request
To: None <>
From: matthew sporleder <>
List: netbsd-users
Date: 11/14/2006 20:59:56
On 11/14/06, George Georgalis <> wrote:
> On Tue, Nov 14, 2006 at 04:25:08PM +0100, Christian Biere wrote:
> >matthew sporleder wrote:
> >> You can also do most of this stuff portably with awk.
> >> Here's an easy example of yesterday: (tested on netbsd and solaris)
> >>
> >> echo|awk 'BEGIN { d = systime() - 86400; } END { print strftime("%c", d) }'
> >
> >You can do the same with "date -r $timestamp +$format" and you can calculate
> >using $(()) in a Bourne shell but I think he wanted to parse dates in different
> >formats, not just print them.
> Yes, exactly. Though I'm very glad to hear that awk supports
> strftime. The task at hand is translating human enterable
> timestamps (ie [[[[[cc]yy]mm]dd]hh]mm[.ss]) into unix seconds (the
> internal format for a db).

Yeah, after reading the thread closely, I got that.  :)
Awk is pretty suited for just that sort of processing/munging, (or
lex, or possibly other included utilities) but it sounds like your
program would be a lot easier to accomplish in something like perl
than to hack together all of this stuff in shell.  I've maintained a
lot of big shell scripts, and they're almost always a mistake.  :)