Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grep for time greater than in a log file. 2

Status
Not open for further replies.

chanman525

IS-IT--Management
Oct 7, 2003
169
US
Hey all, I've got a log file that I would like to pull information out of. I need any instance that is greater than 6:30 and less than 8:00 AM. I really have no idea where to even start on this and was hoping that some of you could put me in the right direction. Here is a portion of the logfile...

OTHPLM184 Out 03/06/07 06:43 Garvey, Brian:S990BG4 335
OTHPLM182 Out 03/06/07 06:45 Byers, Charles:S990CB9 335
SPEC851 Out 03/06/07 06:46 Byers, Charles:S990CB9 335
OTHPLM186 Out 03/06/07 06:49 Martino, Ryan:S990RM6 335
SPEC848 Out 03/06/07 06:49 Martino, Ryan:S990RM6 335


Thanks for any help you can offer.
 
Code:
egrep '0(6:(3[1-9]|[45][0-9])|7:)' logfilename

Should do it.

- Rod


IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 
That works great. I'm wondering though, if you could maybe explain to me how that works. I'm not exactly sure what the numbers inside the brackets are representing. I appreciate the help Rod.
 

Breaking it down:
Code:
0(                     # a zero followed by either
  6:(                  # 6: followed by either
     3[1-9]            # a 3 followed by any digit from 1-9
     |                 # or (inner)
     [45][0-9])        # a 4 or 5 followed by any digit
  |                    # or (outer)
  7:)                  # 7:, any minutes are ok

Hope this helps,

- Rod


IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 
Well that explains that. Also, is there a way to egrep for multiple things, such as the date and the word OUT?
 
egrep "thing|thing|thing"

if you don't know use 'man'


Benno

...it really does get worse than this !!
 
The AIX man page for egrep is less than useful for someone just beginning with regular expressions.

Mastering Regular Expressions covers just about everything you'd ever want to know about them.

- Rod


IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 
...thought man was ok, everything you need is there (not always easy to spot though !) but I must admit if it was presented like your description in this thread then life would be a whole lot easier !!

Benno

...it really does get worse than this !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top