Unix/Linux Go Back    

Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

grep numbers range

Shell Programming and Scripting

Closed Linux or Unix Question    
Thread Tools Search this Thread Display Modes
Old Unix and Linux 08-08-2005
azmathshaikh azmathshaikh is offline
Registered User
Join Date: Mar 2005
Last Activity: 13 April 2008, 6:37 AM EDT
Location: Hyderabad, India
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
grep numbers range

I want to grep a range of numbers in a log file. My log file looks like this:

20050807070609Z;blah blah
That is a combination of yr,month,date,hours,minutes,seconds.
I want to search in the log file events that happened between a particular time.
like between 20050807070000 to 20050822070000 i.i all events happened between 7thAugust 7am until 22nd August 7am.

I tried with grep but in vain.

Help Linux

Sponsored Links
Old Unix and Linux 08-08-2005
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
Join Date: Feb 2005
Last Activity: 12 March 2015, 5:33 AM EDT
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
Use sed.

Assuming you have the start date and end date,

sed -n -e '/20050807070000/,/20050822070000/p' log.file

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Range of numbers in HEX using AWK greycells Shell Programming and Scripting 2 10-07-2011 10:44 AM
grep for a range of numbers tamil.pamaran Shell Programming and Scripting 4 09-21-2011 05:34 PM
Frequency of a range of numbers Gussifinknottle UNIX for Dummies Questions & Answers 1 01-26-2011 03:49 PM
read numbers from file and output which numbers belongs to which range thepurple Shell Programming and Scripting 6 05-13-2009 06:07 AM
Using grep on a range of numbers ProgChick2oo9 UNIX for Dummies Questions & Answers 1 03-15-2009 03:58 PM

All times are GMT -4. The time now is 10:38 AM.