[X-Unix] Question about grep

Our Pal Al opa at avalon.rockefeller.edu
Wed Mar 17 12:31:18 PST 2004


Hmmmm ... I think we're getting there. And I can even follow this! :)

Problems though ...

On 3/17/04 12:07 PM, "Stroller" <MacMonster at myrealbox.com> wrote:
> 
> This seems close to what you require, although I can't immediately seem
> to see how to drop the leading zero, short of using sed.
> 
> $ date
> Wed Mar 17 17:00:11 GMT 2004
> $ let "one_week_ago = `date +%s` - 60 * 60 * 24 * 7"; date -r

Trying this out in a term window, I copy and paste this into my bash shell
and it doesn't work. Error -

"date: option requires an argument -- r
usage: date [-nu] [-r seconds] [+format]
       date [[[[[cc]yy]mm]dd]hh]mm[.ss] "

Is this is something that'll only work in a script? Bear with me. All my
shell scripting needs have been simple so far and there's been nothing I've
made that I couldn't test out line by line first, then just "sew 'em all
together" in a script.

So I guess the idea would be to do multiple greps for today, yesterday, the
day before, etc., appending them all to the same file? Works for me! I just
want to be sure I'm following correctly.

On 3/17/04 12:18 PM, "Stroller" <MacMonster at myrealbox.com> wrote:

> And having wasted all that time on an answer involving long date
> formats, I think the answer is really a weekly `cron` job to
>    mv Restrospect\ backup\ report Restrospect\ backup\ report-`date
> +%Y-%m-%d_%X
> and run your grep on the new one that's subsequently created by the new
> backup.

Hmmm ... I don't think that will work.

Retrospect's exported Backup Report will give me a bigger file every day
with everything going back for months and months, new things not even added
to the top! This is separate from the log. The log is display only and
presented in a window - which I can truncate to an arbitary k limit,
chopping off events too old mid-entry, will-nilly, which isn't really my
preference as I outlined in an earlier post. The Backup Report in contrast
just grows. It's also an optional thing to export and I've never used it
until now.

So if I every day grep the file for that day's events, I will in 7 days have
created a file that goes back a week. And then the next day will go back a
week and a day. Etc, etc.

To consistenly have a file that always has a week's worth of events, I'll
still need to at some point have some date-aware contruct which can age out
old events, not just lop off at a file size, and that brings us back to the
start of this thread.

Whew!

-opa





More information about the X-Unix mailing list