Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

range/pattern matching 1

Status
Not open for further replies.

inforeqd

Technical User
Jan 8, 2001
95
US
I have looked over various readme's and faqs and I have still not been able to find exactly what I need. So here goes:

I have a file that contains a great amount of data. I need to read through this file and extract just a section of it and place it in a seperate file. I was thinking that the range matching ability of awk may help. But still no luck. Any help or guidance (web pages/manuals) that may assist is greatly appreciated.

Thanks
 
inforeqd-

The info you need can be found in:

The AWK Programming Language book on pages:

32, 85, and 187.

Here are some examples:

awk '/dog/ , /cat/ {print}' bigfile > extracted

awk '/dog/ , /^$/ {print}' bigfile > extracted

awk '/NR==11/ , /NR==131/ {print}' bigfile > extracted

The first one uses two string patterns, the second one
uses a string pattern and a blank line, and the third
one uses a range of record lines from 11 through 131.

Hope this helps!



flogrr
flogr@yahoo.com

 
inforeqd-

Sorry, but the third example in my last post
should read:

awk 'NR==11,NR==131{print}' bigfile > extracted

Guess I got carried away with forward slashes!

Good luck.



flogrr
flogr@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top