[英]What does 2>&1 Mean in PowerShell
I have the following script: 我有以下脚本:
if( $timeout -ne $null )
{
& $var$timeout 2>&1 > $logDir\$logName
}
else
{
& $var2>&1 > $logDir\$logName
}
I'm curious about what 2>&1
is; 我很好奇
2>&1
是什么; or, what it represents. 或者,它代表什么。 I don't know what it's called, otherwise, I'd look it up.
我不知道它叫什么,否则,我会查一查。
它将标准错误(2)重定向到与标准输出相同的位置(1)
The docs are your friends. 文档是你的朋友。 From
PS> man about_Redirection
从
PS> man about_Redirection
The Windows PowerShell redirection operators are as follows.
Operator Description Example
-------- ---------------------- ------------------------------
<snip>
2>&1 Sends errors (2) and Get-Process none, Powershell 2>&1
success output (1)
to the success
output stream.
<snip>
The syntax of the redirection operators is as follows:
<input> <operator> [<path>\]<file>
If the specified file already exists, the redirection operators that do not
append data (> and n>) overwrite the current contents of the file without
warning. However, if the file is a read-only, hidden, or system file, the
redirection fails. The append redirection operators (>> and n>>) do not
write to a read-only file, but they append content to a system or hidden
file.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.