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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grep help, or at least I think it is? 1

Status
Not open for further replies.

jewel464g

Technical User
Jul 18, 2001
198
US
I have a file that is 605MB. I need to get the information that starts on line 11508585 and goes through line 11510676. I used grep to match the time pattern and then find the line numbers but I need everything between those 2 line numbers. Anybody have an idea what I can do to get them? I'm relatively new to Linux so please be patient :)

Jewel

When faced with a decision, always ask, 'Which would be the most fun?'
 
Jewel,

What you want to use is csplit.

I've used it many times to do exactly what you want to do. It's a very handy utility. Read the man page, it'll explain how to do the options.

Patrick

Patrick Bartkus, CCNP, CNX, SCM Sr. Network Engineer
GA Dept of Labor IT Network Services
If truth were not absolute, how could there be justice?
 
Ok so you have that 605MB file and you want to display only lines 11508585 through to 11510676 (inclusive) why not use awk?

awk 'NR==11508585, NR==11510676{print NR $0}' your_file.txt

To explain:
awk sees a file as a set of records with a end of line marker as the end of each record.

awk '{print NR $0}' ......

This prints out each line with the record number at teh start of each line.

awk NR==number, NR==number{prin.....
starts the output from line number through to line number

Try it see what you get .... just remove the NR after the print part once you trust the output to see a clean set of records

Good Luck
Laurie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top