cmd escape character ^
cmd转义字符
A caret (^) character in a command line means that the character immediately following it is interpreted literally
^字符可以用来在命令行中用来转义,一个例子
to set the output of var into a variable without creating a temp file, go a bit more complex with:
for /f "delims=" %a in ('ver ^| findstr /v "linux"') do @set myvar=%a
check it with:
echo %myvar%
上面的例子中, ver ^| 转义了|,告诉cmd这个命令ver ^| findstr /v "linux" 是一个完整的命令, 这样shell就不会将for /f "delims=" %a in ('ver ^认为是一个将标准输出重定向到findstr /v "linux"') do @set myvar=%a标准输入的命令了。
find more on the caret command
更多的关于^的内容, 请看 Batch: Escaping with caret 和How to avoid cmd.exe interpreting shell special characters like <> ^.
References
How to avoid cmd.exe interpreting shell special characters like <> ^