troubleshooting Question

Extract a few lines from a large file

Avatar of klyles95
klyles95 asked on
PerlRegular ExpressionsLinux OS Dev
6 Comments1 Solution575 ViewsLast Modified:
I have a large pipe delimited file with approx. 2.3 million rows (records).

I am attempting to locate a particular record.  However I do not have any information regarding the record of interest but I believe that I have information about a record that may be close to it.  So essentially I want to look for the record that I know about, once string is found, I'd like it to write the contents of that line plus a specified number of lines that follows the found string to see if I can identify my missing record.  

 How can I be looking for a record I don't know about?  It is based on counts.  I am missing a single record and based on what was inserted into a database I have pointed the last record that was inserted and I believe the record that is missing should have been inserted after that.

The record that I have information on commences with the following:
D|12345678

The numeric is a unique number.  So I want to be able to get the row where this text appears, output the entire line and print an additional say 3 - 10 lines (or how many lines I desire after) to see if I can locate the missing record.

I have been reading about grep, sed, awk and I am at a total loss how to implement.  I do not want to have to open such a large file and scan to this location in order to find my record.

Any help would be greatly appreciated.
ASKER CERTIFIED SOLUTION
klyles95

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros