I can pass a double quote and more than a character to any command in several ways: '"' , "\"" , ">"
But when I try to transfer them together
C:\>echo "\">" The system cannot find the path specified.
Same thing with "\"\>" . I could make it work with single quotes, but since I already have so much work with quotes, I would like to keep all this inside double quotes.
Is there any way to avoid this?
I'm on windows7, but I think this is some kind of backward compatibility feature, so I'm not sure if this information matters.
Change 1:
I had Endoro's correct answer ... but it is not so simple. CMD treats ^> differently depending on whether there is a hidden double quote in the string. Does anyone know why ?! or another way of shielding?
C:\>sh echo "\"^>" "> C:\>sh echo "a^>" a^> C:\>echo "\"^>" "\">" C:\>echo "a^>" "a^>"
Edit 2: here are sample tests for what Monacraft suggested, using ^ before quotes that go around the string
C:\>echo ^"a/>" The system cannot find the path specified. (we still need to escape that > symbol) C:\>echo ^"a/^>" "a/>" (work fine without \" in the string) C:\>echo ^"\"/^>" "\"/^>" (add a single \" and the ^> escaping stop to works) C:\>echo ^""/^>" ""/^>" (ok, using ^ before the string means i dont have to escape the " anymore) C:\>echo ^"^\"/^>" "\"/^>" (but what if i have an actual \" in my input that i have to escape... would ^\ prevent this from happening? nope)
source share