!["exec &>/dev/null" 중간에 있는 &는 무엇을 합니까?](https://linux55.com/image/114369/%22exec%20%26amp%3B%26gt%3B%2Fdev%2Fnull%22%20%EC%A4%91%EA%B0%84%EC%97%90%20%EC%9E%88%EB%8A%94%20%26amp%3B%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9D%84%20%ED%95%A9%EB%8B%88%EA%B9%8C%3F.png)
내 명령은 다음과 같습니다
exec &>/dev/null
여기서 & 및 전체 명령은 무엇을 하고 있나요? bitbucket으로 리디렉션되는 것으로 알고 있습니다.
답변1
이것은 &>
단지 가 아닙니다 &
.
에서는 표준 출력 및 표준 오류 스트림을 어딘가로 리디렉션합니다 bash
.&>
따라서 .utility &>/dev/null
utility >/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.