/dev/null" 真ん中の & は何をしますか?">

"exec &>/dev/null" 真ん中の & は何をしますか?

/dev/null" 真ん中の & は何をしますか?">

私のコマンドは次のとおりです。

exec &>/dev/null

ここで&と完全なコマンドは何をしていますか? bitbucketにリダイレクトされることを知っています。

ベストアンサー1

これは&>単なるものではありません&

では、標準出力と標準エラーストリームをどこかにリダイレクトしますbash&>

したがってutility &>/dev/nullutility >/dev/null 2>&1

このコマンドは、exec &>/dev/null現在のシェルの2つの出力ストリームを次にリダイレクトします/dev/null(つまり、その時点で始まるスクリプトのすべての出力、エラー、またはその他の内容を削除します)。

マニュアルの関連部分bash

Redirecting Standard Output and Standard Error                              
   This construct allows both the standard output (file descriptor 1) and  
   the standard error output (file descriptor 2) to be redirected to the   
   file whose name is the expansion of word.                               

   There are two formats for redirecting standard output and standard      
   error:                                                                  

          &>word                                                           
   and                                                                     
          >&word                                                           

   Of the two forms, the first is preferred.  This is semantically         
   equivalent to                                                           

          >word 2>&1                                                       

   When using the second form, word may not expand to a number or -.  If   
   it does, other redirection operators apply (see Duplicating File        
   Descriptors below) for compatibility reasons.                           

おすすめ記事