2

I have a lot of big text files. And I'm searching (within cmd.exe) for a list of values in them as following:

findstr /i /n /g:strings.txt 1\*.* >results.txt 

where strings.txt is the file with all the values I'm looking for and 1 is a folder where all my text files are.

There is valuable information in preceding and next strings to the one that I can find with findstr. Could you please help me writing a script to have 3 lines in results.txt for each match?

1
  • 1
    Can you use Powershell? Commented Mar 28, 2016 at 14:01

1 Answer 1

1

Powershell. Specifically, the -Context parameter of the Select-String Cmdlet will give you the context surrounding the selected text.

PS C:\Users\ryan> gc .\temp.txt 1 2 3 4 5 6 7 8 9 10 PS C:\Users\ryan> gc .\temp.txt | Select-String '4' -Context 3 1 2 3 > 4 5 6 7 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.