Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-05-2008
Registered User
 

Join Date: Apr 2008
Posts: 10
Grep help

I want to grep a range of times from a file.

File looks like this:
Jun 1 8:50:18
Jun 1 8:53:22
Jun 1 8:59:43
Jun 1 9:34:23
Jun 1 10:02:00
Jun 1 11:02:00
Jun 1 11:03:00
Jun 1 12:02:00
Jun 1 23:55:59

I want to grep for "Jun 1" but I want times 8-11.

I know its easy, but Im new!
Sponsored Links
  #2 (permalink)  
Old 06-05-2008
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Try this:


Code:
awk '/^Jun 1/ { n=$3; gsub(":", "", n); if (n >= 80000 && n <= 110000) print; }' input_file.txt

  #3 (permalink)  
Old 06-05-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 759

Code:
grep -E "Jun 1 (8|11)" file

  #4 (permalink)  
Old 06-06-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Actually


Code:
egrep 'Jun 1 ([89]|1[01])' file

... if you want everything between those times. (Maybe leave out the 11 if you only want through 10:59.)
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep Aejaz UNIX for Advanced & Expert Users 3 04-30-2008 08:10 AM
help on grep prvnrk Shell Programming and Scripting 5 01-08-2008 05:47 AM
grep dineshr85 Shell Programming and Scripting 1 10-10-2007 05:52 AM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-05-2007 03:59 AM
Make grep -c display like grep -n? Jerrad Shell Programming and Scripting 2 08-25-2006 01:20 AM



All times are GMT -4. The time now is 08:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0