Register
It is currently Sat Oct 25, 2014 6:17 pm

Copying specific lines containing keyword from text file


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue May 19, 2009 12:58 am   

Joined: Tue May 19, 2009 12:34 am
Posts: 8
I have a very long text file (> 9M lines)
and I need to extract certain information from it, but I am failing :(

I am trying to write a script that searches through the textfile for a KEYWORD or KEYPHRASE, and copies the (whole) line and the 7 lines directly beneath.
It should do this for every time the keyword/keyphrase appears in the text file.

Please help


Top
 Profile  
 PostPosted: Tue May 19, 2009 2:44 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Code:
egrep -A7 'KEYWORD|KEYPHRASE' myfile.txt


Top
 Profile  
 PostPosted: Wed May 20, 2009 12:34 am   

Joined: Tue May 19, 2009 12:34 am
Posts: 8
Marvellous, thankyou. So simple :-)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP