combine findstr and more?

October 29, 2009 at 23:44:54
Specs: Windows XP

I would like to search a text file for "Y", and then print the 4 lines immediately following it to another text file. I have tried various syntax of findstr and more commands to no avail.

Thank You.

See More: combine findstr and more?

Report •

November 8, 2009 at 08:48:56
FINDSTR will do the search part, but you indeed need something else to extract the 4 lines.

MORE may be suited, because it CAN accept line numbers, maybe you need to use this parameter from FINDSTR :

/N Prints the line number before each line that matches.

Report •

November 9, 2009 at 05:46:11
if you can download stuff, use GNU grep. See my sig for link.
grep -A 4 "YYY" file

much better than findstr

GNU win32 packages | Gawk

Report •

November 15, 2009 at 01:01:59
I did contemplate using the line number scheme, but then I would have to implement a counter and variables or something somehow to get found line + next four lines, which I have no freaking clue how, my talents are meager.

But I like the idea of just using a more powerful program, that should suit my purpose. Thanks guys.

Report •

Related Solutions

Ask Question