The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
HOW to egrep fo a pattern eliewadi Shell Programming and Scripting 1 05-15-2008 07:42 PM
nawk-how count the number of occurances of a pattern, when don't know the pattern cyber111 Shell Programming and Scripting 2 05-11-2008 12:00 AM
Egrep cheat sheet anywhere? Looking for meaning of egrep -c leelm UNIX for Dummies Questions & Answers 2 01-11-2008 11:37 AM
Pattern searching pattern in c files murthybptl Shell Programming and Scripting 6 11-17-2007 05:15 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 11:41 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2007
Registered User
 

Join Date: Jun 2007
Posts: 3
egrep a certain pattern

hey guys this is my first post here, heard a lot about these forums. Iam urgently in need of a command which would help me accomplish the following , for example a file has these contents:

211 61 2007-06-26 13:47:32
211 61 2007-06-26 09:53:43
211 61 2007-06-26 15:25:14
211 61 2007-06-26 04:32:11
211 61 2007-06-26 21:12:36
211 61 2007-06-26 02:11:27



now , i need to EGREP a pattern which would give me the following output:

211 61 2007-06-26 13
211 61 2007-06-26 09

basically, all lines are same.. what i need to EGREP is in each line "the range of grepping would be from 211 to hours i.e 00,12,09 etc.

egrep -e "211 2007-06-26 $$" ??

date is fine ,everything is same..i just need to know the command which would grep me the contents uptil the 2 digits of HOURS.


urgent reply needed!! thanks!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-29-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Can you please explain what do you mean by 2 digits of HOURS?
Reply With Quote
  #3 (permalink)  
Old 06-29-2007
Registered User
 

Join Date: Jun 2007
Posts: 3
hello !

by two digits i mean


13:47:56
14:11:21:


basically 13 and 14 are the 2 digits

i need an output which would begin from 211 and end on the 2 digits of the hours , e.g. following is what i desire as a result:

211 61 2007-06-26 13
211 61 2007-06-26 09
211 61 2007-06-26 01
211 61 2007-06-26 00
211 61 2007-06-26 12
211 61 2007-06-26 06

so u see it is showing 2 digits of hours, no minutes or seconds after that.

basically this is a 300 mb text file which is showing 211 61 transactions with date and time

i need to know the command so it can show uptil HOURS only (no minutes or seconds) so i can see which transaction is made at what hour (no minutes or seconds)
Reply With Quote
  #4 (permalink)  
Old 06-29-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
cut -d':' -f1 filename
Reply With Quote
  #5 (permalink)  
Old 06-29-2007
Registered User
 

Join Date: Jun 2007
Posts: 3
wow thanks a lot anbu23!!!!!

now iam facing another problem

ok for example i need to grep only the transaction of 14th hour i will do this:

cut -d':' -f1 filename|grep "14"

it will show:
211 61 2007-06-26 14
211 61 2007-06-26 14
211 61 2007-06-26 14
211 61 2007-06-26 14


now what if i need to see the files which are of 00 hour??

cut -d':' -f1 filename|grep "00"

if i do this it will show all the files because 2007 also has two zeros.
Reply With Quote
  #6 (permalink)  
Old 06-29-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
awk -F":" ' $1 ~"00$" ' filename
Code:
cut -d':' -f1 filename|grep "00$"
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0