Please correct me if I am wrong, but I think I understood:
findstr.exe /misc:^"namespace=\^"^" *.cs > ns.txt
This seems to give the correct output, even if there are spaces in the search bar. This allows you to redirect files, pipes, and additional literals in the same findstr.exe call to work correctly.
The original command in my question does not work, because both cmd.exe and findstr.exe have special processing for the character. " I ended up with an unsurpassed set of quotes in the cmd.exe processing.
The new command in my answer works because ^" allows you to pass a quote from cmd.exe to findstr.exe, and \" tells findstr.exe to ignore this quote for command processing purposes and treat it as a character literal.
Edit
Well, my decision was right, but the reason that it was right was completely wrong. I wrote a small program for testing.
I found out that cmd.exe passes this input to the program when I pass a bad command line:
test.exe /misc:namespace=" *.cs > ns.txt
If the characters are reset correctly, cmd.exe passes this input to the program (and redirects the output to a file):
test.exe /misc:namespace=" *.cs
Merlyn morgan-graham
source share