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!

egrep help...

Status
Not open for further replies.

chanman525

IS-IT--Management
Oct 7, 2003
169
US
I have a log file that I'm trying pull information out of. The information needs to be between noon and the end of the day. My line of code is the following...

egrep '1([2-9]:([0-9][1-9]))|2([0-3]:)' ma.log > ma1.LOG

When I run this, it places all of this into the file...

+1 Wed Apr 18 00:17:41 EDT 2007 : License 78768771 for item 63157 deleted by maj
+2 Wed Apr 18 02:19:37 EDT 2007 : Radio 253 reset by maj
+3 Wed Apr 18 02:19:45 EDT 2007 : Radio 253 reset by maj
+4 Tue Apr 17 03:20:30 EDT 2007 : Radio s990rm3 reset by maj
+5 Tue Apr 17 03:20:43 EDT 2007 : Radio 163 reset by maj
+6 Tue Apr 17 19:18:33 EDT 2007 : RF work for s990ts10 moved [90]-[258] by maj
+7 Tue Apr 17 19:33:08 EDT 2007 : RF work for s990cm14 moved [150]-[300] by maj
+8 Tue Apr 17 20:07:26 EDT 2007 : Radio 204 reset by maj
+9 Tue Apr 17 22:03:04 EDT 2007 : Radio 351 reset by maj
+10 Tue Apr 17 22:41:39 EDT 2007 : Radio 253 reset by maj
+11 Tue Apr 17 23:20:19 EDT 2007 : Radio 253 reset by maj
~



I have no idea what I'm missing. I thought that egrep string would only pull information from noon on. Can anyone see if I'm doing something wrong here?
 
Hi,

Is is the minutes and seconds that meet the pattern in your log, not hours and minutes.
try this:
Code:
egrep '1[2-9]:[0-5][0-9]:|2[0-3]:[0-5][0-9]:' ma.log > ma1.LOG
 
If you're not married to egrep, this should do it:
Code:
perl -ne '
if ( $_ =~ /\s(\d\d):/ )
{
 print if $1 >= 12;
}
' ma.log > ma1.LOG

- 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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top