Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

grep numbers range

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 08-08-2005   -   Original Discussion by azmathshaikh
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   -   Original Discussion by azmathshaikh
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
Join Date: Feb 2005
Last Activity: 8 February 2016, 5:12 PM EST
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

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 11:44 AM
grep for a range of numbers tamil.pamaran Shell Programming and Scripting 4 09-21-2011 06:34 PM
Frequency of a range of numbers Gussifinknottle UNIX for Dummies Questions & Answers 1 01-26-2011 04:49 PM
read numbers from file and output which numbers belongs to which range thepurple Shell Programming and Scripting 6 05-13-2009 07:07 AM
Using grep on a range of numbers ProgChick2oo9 UNIX for Dummies Questions & Answers 1 03-15-2009 04:58 PM

All times are GMT -4. The time now is 02:23 PM.