You need to worry about escaping quotes for both grep and cmd.exe
grep expects quotes to be escaped as \"
cmd.exe marks quotation marks as ^" . Quotation is a finite state machine meaning non-exclusive quotation marks to enable or disable quotation semantics. When quoting is turned on, special characters such as < , | , & etc., are treated as literals. first vague citation includes semantics quotes. The following quote disables semantics citations. Turn a quote can only be switched off when quoting. Unbalanced quotes lead to citation residue. Thus, in your case >>tmp.txt is not regarded as a redirection cmd.exe, so it is passed to grep as an argument.
Any of the following actions will be performed:
grep -r "Assembly=\"Foobar^" . >>tmp.txt grep -r ^"Assembly=\"Foobar" . >>tmp.txt grep -r ^"Assembly=\^"Foobar^" . >>tmp.txt grep -r Assembly=\^"Foobar . >>tmp.txt
If your search query included spaces, then grep needs the enclosed quotation marks, therefore you will need any of the first three forms. The last form will not work with spaces in the search expression.
source share