Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a requirement where I have to scan a file, search for a string and print the next 10 lines of the file starting from the line where the string was found.
E.g. MyFile
This is line1
This is line2
Did you Findme
This is line3
This is line4
.
.
.
String to find "Findme"
Output should be
Did you Findme
This is line3
This is line4
.
.
.
Also, the output should be written to another file
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching for a string in a text and printing the next few lines
by Corion (Patriarch) on Nov 12, 2009 at 13:34 UTC | |
by sierpinski (Chaplain) on Nov 12, 2009 at 15:47 UTC | |
|
Re: Searching for a string in a text and printing the next few lines
by Utilitarian (Vicar) on Nov 12, 2009 at 13:45 UTC | |
|
Re: Searching for a string in a text and printing the next few lines
by ww (Archbishop) on Nov 12, 2009 at 23:33 UTC | |
by Anonymous Monk on Nov 13, 2009 at 10:32 UTC | |
by ww (Archbishop) on Nov 13, 2009 at 12:20 UTC |