"exec &>/dev/null" 중간에 있는 &는 무엇을 합니까?

"exec &>/dev/null" 중간에 있는 &는 무엇을 합니까?

내 명령은 다음과 같습니다

exec &>/dev/null

여기서 & 및 전체 명령은 무엇을 하고 있나요? bitbucket으로 리디렉션되는 것으로 알고 있습니다.

답변1

이것은 &>단지 가 아닙니다 &.

에서는 표준 출력 및 표준 오류 스트림을 어딘가로 리디렉션합니다 bash.&>

따라서 .utility &>/dev/nullutility >/dev/null 2>&1

이 명령은 exec &>/dev/null현재 셸의 두 출력 스트림을 다음으로 리디렉션합니다 /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.                           

관련 정보