32

次のスクリプトがあります。

if( $timeout -ne $null )
{
    & $var$timeout 2>&1 > $logDir\$logName
}
else
{
    & $var2>&1 >  $logDir\$logName
}

私は何であるかについて興味2>&1があります。または、それが表すもの。私はそれが何と呼ばれているのか知りません。

4

2 に答える 2

30

ドキュメントはあなたの友達です。から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.
于 2013-07-29T18:57:19.323 に答える