Home > Archive > AWK > May 2004 > Interesting gotcha
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Interesting gotcha
|
|
| Robert Peirce 2004-05-12, 7:19 pm |
| I have a script that uses awk to create a time-stamp._ Suddenly I seem
to be overrun with spurious, zero length files._ It turns out that the
time-stamp is supposed to be MMddhhmm, but the date wasnąt getting a
leading zero, so touch was creating two files 05 & 6hhmm, instead of
0506hhmm._ The solution was to check if the date was less than 10 and to
prepend a 0 to it.
--
Robert B. Peirce, Venetia, PA 724-941-6883
bob AT peirce-family.com [Mac]
rbp AT cooksonpeirce.com [Office]
| |
| Don Stokes 2004-05-12, 7:19 pm |
| In article <bob-D96454.20244706052004@news-central.ash.giganews.com>,
Robert Peirce <bob@peirce-family.com.invalid> wrote:
>I have a script that uses awk to create a time-stamp._ Suddenly I seem
>to be overrun with spurious, zero length files._ It turns out that the
>time-stamp is supposed to be MMddhhmm, but the date wasnąt getting a
>leading zero, so touch was creating two files 05 & 6hhmm, instead of
>0506hhmm._ The solution was to check if the date was less than 10 and to
>prepend a 0 to it.
Huh?
$ gawk 'BEGIN { print strftime("%m%d%H%M") }'
05071429
No spaces in sight.
How are you generating your timestamps?
-- don
| |
| Robert Peirce 2004-05-12, 7:19 pm |
| In article <cxCmc.444$FN.43049@news02.tsnz.net>,
don@news.daedalus.co.nz (Don Stokes) wrote:
> In article <bob-D96454.20244706052004@news-central.ash.giganews.com>,
> Robert Peirce <bob@peirce-family.com.invalid> wrote:
>
> Huh?
>
> $ gawk 'BEGIN { print strftime("%m%d%H%M") }'
> 05071429
>
> No spaces in sight.
>
> How are you generating your timestamps?
>
> -- don
From ls -l file. I use awk to convert them to strings touch will
recognize. I grab field 6-8 and set d = $2 [field 7], which works fine
about 2/3 of the time. The other third I have to be careful to add a
leading 0.
--
Robert B. Peirce, Venetia, PA 724-941-6883
bob AT peirce-family.com [Mac]
rbp AT cooksonpeirce.com [Office]
|
|
|
|
|