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?
CodePudding user response:
(@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.