을 cat > myfile &
문제에 실행. in terminal : 스크립트의 일부로 실행되지 않는 경우 : 비대화 형 배경이 command &
인 stdin
은 /dev/null
에서 암시 적으로 리디렉션됩니다.
스크립트에서 cat > myfile &
은 실제로 cat </dev/null > myfile
으로 변환되어 즉시 cat
으로 끝납니다.
셸 명령 언어 &
Asynchronous Lists에 POSIX 표준을 참조하십시오
영원히 열려있는,하지만 아무것도하지 않고 파일을 유지해야하는 이유 확신
The standard input for an asynchronous list, before any explicit redirections are
performed, shall be considered to be assigned to a file that has the same
properties as /dev/null. If it is an interactive shell, this need not happen.
In all cases, explicit redirection of standard input shall override this activity.
# some tests
sh -c 'sleep 10 & lsof -p ${!}'
sh -c 'sleep 10 0<&0 & lsof -p ${!}'
sh -ic 'sleep 10 & lsof -p ${!}'
# in a script
- cat > myfile &
+ cat 0<&0 > myfile &
하지? 폴더를 삭제하지 않기 위해서입니까? –