[X-Unix] Question about grep

James Avgeris jima at itempo.com
Tue Mar 16 17:46:32 PST 2004


> So in a file with lots of lines like this -
>
> 3/15/2004    5:58 PM    Drogo-OS X (21.177)    Macintosh HD    -24001
> user canceled    0:34:00    129.85.21.177
>
> How can I formulate grep to grab on the mm/dd/yyyy field and pull out 
> "any
> lines where the date is no older than 7 days ago"?

Here's how I'd do it, but unfortunately you'd have to give it a 
different date range each week:

grep -e "^3\/[7-9]" -e "^3\/1[0-5]" filename | grep -v 'Successful'

-Jim



More information about the X-Unix mailing list