Operating System - HP-UX
1833707 Members
2587 Online
110063 Solutions
New Discussion

grep on snmp collected data

 
SOLVED
Go to solution
Seun Ewulomi_1
Honored Contributor

grep on snmp collected data

Hi people,

I have a huge ascii text file with data collection point. the text file is of the form(below)

How could I use grep/awk to grep for data between a time frame

In Kbits R1 6/1.10 3/105 to R2 31/10/03 10:15:00 3657.07
In Kbits R1 6/1.10 3/105 to R2 31/10/03 10:20:00 3976.85
In Kbits R1 6/1.10 3/105 to R2 31/10/03 10:25:00 5088.18
In Kbits R1 6/1.10 3/105 to R2 31/10/03 11:00:00 3471.26
In Kbits R1 6/1.10 3/105 to R2 31/10/03 11:05:00 4311.4
In Kbits R1 6/1.10 3/105 to R2 31/10/03 11:10:00 2000.9
In Kbits R1 6/1.10 3/105 to R2 31/10/03 12:50:00 3021.64
In Kbits R1 6/1.10 3/105 to R2 31/10/03 12:55:00 3385.86
In Kbits R1 6/1.10 3/105 to R2 31/10/03 13:00:00 3483.98
In Kbits R1 6/1.10 3/105 to R2 31/10/03 13:05:00 3920.98
In Kbits FR1 6/1.10 3/105 to R2 31/10/03 14:00:00 5627.66
In Kbits R1 6/1.10 3/105 to R2 31/10/03 14:05:00 5252.07
In Kbits R1 6/1.10 3/105 to R2 31/10/03 14:10:00 3768.24

I can use awk and grep to get required columns and to get data for a set date but I dont know how to grep for data for between time frames in a day.

From the week data to get all data for a certain date i usually use

$ grep '^03/.*/2003'


BUT If I would like to see all data within a week between 10am and 14pm how can I do this?

Can someone please help as I think have tried everything to my knowledge and understanding

Any help will be greatly appreciated

regards,
gab
Jesus Christ is LORD
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: grep on snmp collected data

Gab,

I'm attaching the "Handy One Liners for Sed". I think the "# print section of file between two regular expressions (inclusive)" one liner might be just the ticket for you.


Pete

Pete
john korterman
Honored Contributor
Solution

Re: grep on snmp collected data

Hi,
maybe you have already tried this simple approach: if you have the exact time specifications you can specify begin and end time, e.g. like this:
# awk '/31\/10\/03\ 10:15:00/,/31\/10\/03\ 14:00:00/' <./infile

which will print the lines from 31/10/03 between 10:00 and 14:00. However, it will of course only work if both the exact begin and end specifications are present.

regards,
John K.
it would be nice if you always got a second chance
Rodney Hills
Honored Contributor

Re: grep on snmp collected data

How about this awk one-liner

awk -v D="31/10/03" -v T1="10:20:00" -v T2="13:00:00" 'BEGIN{p=0};$9 >= T1{p=D};$9 <= T2{p=0};{if (D == $8) print $0}'
Set variables D,T1,T2 to the values you are searching.

HTH

-- Rod Hills
There be dragons...
Seun Ewulomi_1
Honored Contributor

Re: grep on snmp collected data

Hi guys,

It worked like a charm. Thanks Pete on the sed document. I shall start to digest this.

regards,
gab
Jesus Christ is LORD