[X-Unix] Question about grep

Stroller MacMonster at myrealbox.com
Wed Mar 17 09:07:00 PST 2004


On Mar 17, 2004, at 3:08 pm, Our Pal Al wrote:
>
> I know there's a 'date' command in the shell and was hoping there was 
> some
> simple way to combine it with grep to get what I need, but I'm at my 
> limit
> there.

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 
$one_week_ago +%m/%e/%Y
  03/10/2004

(you may additionally need to change the %e to %d if Retrospect uses 
two-digit format for days-of-the-month < 10.

> There may even be other "time aware" commands besides 'date' but I
> have no clue if they even exist or not.

`man date` also mentions `man strftime`, which you may find useful.

Stroller.



More information about the X-Unix mailing list