0

This command works fine - getting a range of lines and text

for /r %i in (*) do type %i|findstr/n ^^|findstr " ^30[6-9]: black blue

But the following command won't put the output to a file

for /r %i in (*) do type %i|findstr/n ^^|findstr " ^30[6-9]: black blue >>save.txt

What is the syntax that I need to use?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
southskies
  • 133
  • 1
  • 8

1 Answers1

0
(@for /r %i in (*) do @type %i|findstr/n ^^|findstr " ^30[6-9]: black blue")>>x.txt

The search-strings need to be quoted - the end-quote is missing. The @s suppress the command-echo.

The enclosing parentheses are required if you use a single > as a redirector, which creates a new file. If you use >> then they are optional. Without them, each individual findstr's output is appended to the file, which opens/closes the output file many times. WIth them, it's the for output that's redirected to the file.

Magoo
  • 77,302
  • 8
  • 62
  • 84