UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 20th, 2006, 03:34 AM
Kuramanga Kuramanga is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: Oxford, England
Posts: 17 Kuramanga User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 43 m 39 sec
Reputation Power: 0
Post Using awk to take lines from a 15Mb file and place in a new file

Hey guys,

I have a 15Mb text file, has around 170,000 lines in it.

I want to be able to search the file for a specific word e.g. Kura and have every line that has the word Kura in inserted into a new file.

Can anyone help me?

Thanks in advance.

Reply With Quote
  #2  
Old July 20th, 2006, 03:42 AM
spoon! spoon! is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 247 spoon! User rank is Second Lieutenant (5000 - 10000 Reputation Level)spoon! User rank is Second Lieutenant (5000 - 10000 Reputation Level)spoon! User rank is Second Lieutenant (5000 - 10000 Reputation Level)spoon! User rank is Second Lieutenant (5000 - 10000 Reputation Level)spoon! User rank is Second Lieutenant (5000 - 10000 Reputation Level)spoon! User rank is Second Lieutenant (5000 - 10000 Reputation Level)spoon! User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 8 h 15 m 23 sec
Reputation Power: 77
something like
Code:
grep Kura file > newfile
Comments on this post
SimonJM agrees: Simple, but effective

Reply With Quote
  #3  
Old July 20th, 2006, 03:48 AM
Kuramanga Kuramanga is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: Oxford, England
Posts: 17 Kuramanga User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 43 m 39 sec
Reputation Power: 0
Ok now I feel liek a total nub.

Thankyou for that, didn't realise it was so easy.

Reply With Quote
  #4  
Old July 20th, 2006, 05:07 AM
mu's Avatar
mu mu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: Dublin, Ireland
Posts: 174 mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level)mu User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 23 h 39 m 56 sec
Reputation Power: 39
If you want to match the word 'Kura' and not 'Kuramanga' etc. you should use something like:

Code:
grep '\<Kura\>' file > newfile

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Using awk to take lines from a 15Mb file and place in a new file


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT