What does >& mean?
I was a little confused by this expression:
gcc -c -g program.c >& compiler.txt
알고있어요&>filename
stdout과 stderr을 모두 파일로 리다이렉트합니다.filename
단, 이 경우 앰퍼샌드는 보다 큰 기호 뒤에 있습니다.형태인 것 같다M>&N
,어디에M
그리고.N
파일 기술자입니다.
위의 스니펫에서 다음을 수행합니다.M=1
그리고.N='compiler.txt'
? 이 기능은 다음 제품과 정확히 어떻게 다릅니까?
gcc -c -g program.c > compiler.txt (ampersand removed)
My understanding is that each open file is associated with a file descriptor greater than 2. Is this correct?
If so, is a file name interchangeable with its file descriptor as the target of redirection?
이것은 와 같다.&>
. bash manpage에서:
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 equiva- lent to >word 2>&1
&>
대>&
: 권장 버전은 다음과 같습니다.&>
(클러버)
Regarding:
&>
>&
둘 다 파일을 클로버합니다.파일을 쓰기 전에0 바이트로 잘라냅니다.> file
STDIN만의 경우로 충분합니다.
However, the bash
manual Redirections section adds that:
Of the two forms, the first is preferred. This is semantically equivalent to
>word 2>&1
두 번째 양식을 사용할 때 단어는 숫자로 확장되지 않을 수 있습니다.
-
이 경우 호환성을 위해 다른 리다이렉트 오퍼레이터가 적용됩니다(아래 '파일 기술자 복제' 참조).
(Note: in zsh
both are equivalent.)
첫 번째 손가락을 사용할 수 있도록 연습하는 것은 매우 좋은 방법입니다.&>
( ) 폼, 이유:
사용하다&>>
~하듯이>>&
는 지원되지 않습니다.bash
(표준)
There's only one append form:
The format for appending standard output and standard error is:
&>>word
This is semantically equivalent to
>>word 2>&1
(see Duplicating File Descriptors below).
Note:
- 의 clobber 사용 현황
&>
에 걸쳐서>&
에 추가할 수 있는 방법은 하나뿐이므로 위의 항에서 다시 권장합니다.bash
. zsh
둘 다 허용&>>
그리고.>>&
폼을 클릭합니다.
주제에서 약간 벗어나긴 하지만 이래서 긴 폼을 고집하는 거야>/dev/null 2>&1
항상요.이것은 cron과 같이 cron 위에 > &, &> > &, &> ...을 추가하지 않고 거꾸로 하는 사람들에게는 충분히 혼란스러운 일입니다.에 자주 메모를 추가해야 합니다.crontab -l
「2 > & 1 > /dev/filename」은 베스트 프랙티스가 아님을 상기시킵니다.
「최종 행선지」가 최초로 주어지는 것을 기억하고 있는 한, Bourne과 같은 셸을 사용하는 Unix 또는 Unix와 같은 시스템에서 추가 또는 그 외의 구문을 사용할 필요가 있습니다.게다가, 그 이후로는&>
는 사실상 Bash-ism(csh에서 유래했을 가능성이 있습니다.기억은 안 됩니다만, POSIX는 어느 쪽도 아닙니다)입니다.로크다운된 상용 UNIX 시스템에서 항상 지원되는 것은 아닙니다.
ReferenceURL : https://stackoverflow.com/questions/11255447/what-does-mean
'programing' 카테고리의 다른 글
목록 내의 여러 data.frames를 동시에 Marge합니다. (0) | 2023.04.23 |
---|---|
Swift에서 빈 어레이를 만드는 방법 (0) | 2023.04.23 |
dyld: 라이브러리가 로드되지 않았습니다: @rpath/libswiftCore.dylib (0) | 2023.04.23 |
매일 오후 10시에 cron을 한 번 실행하는 방법 (0) | 2023.04.23 |
맨 아래 행을 선택하는 방법 (0) | 2023.04.23 |