shell command 에러 출력 막는 방법에 대한 문의
글쓴이: ssanighe / 작성시간: 화, 2007/05/15 - 5:22오후
[root@ssanighe]# cat test/vmstat.txt cat: test/vmstat.txt: No such file or directory [root@ssanighe]# cat test/vmstat.txt >/dev/null 2>&1 [root@ssanighe]#
위의 예제를 보시면, 에러를 출력하지 않기 위해
stdout 과 stderr 을 /dev/null 로 보내버렸습니다.
그런데, 아래 예제처럼 "test" 디렉토리가 없을때,
에러를 출력하지 않으려면 어떻게 해야 될지요..
궁굼합니다.
[root@ssanighe]# vmstat > test/vmstat.txt -bash: test/vmstat.txt: No such file or directory [root@ssanighe]# vmstat > test/vmstat.txt 2>/dev/null -bash: test/vmstat.txt: No such file or directory
Forums:
원하시는 답이
원하시는 답이 아닐지도 모르지만 다음과 같은 방법도 있습니다.
test 디렉토리가 있을 때만 뒤쪽 명령이 실행됩니다.
vmstat 2>/dev/null >
브라보!
브라보!
댓글 달기