Notice
Recent Posts
Recent Comments
준호씨의 블로그
linux - Hide "No such file or directory" when 'cat' nonexistent file 본문
반응형
You can see stderr "No such file or directory" when you 'cat' none exists file
$ cat nonexistent_file
cat: nonexistent_file: No such file or directory
If you want to hide stderr, attach 2>/dev/null after command
cat nonexistent_file 2>/dev/null
Tip
'grep' command has '-s' option to hide error message about nonexistent or unreadable files.
-s, --no-messages
Suppress error messages about nonexistent or unreadable files. Portability note: unlike GNU grep, 7th Edition Unix grep did not conform to POSIX,
because it lacked -q and its -s option behaved like GNU grep’s -q option. USG-style grep also lacked -q but its -s option behaved like GNU grep.
Portable shell scripts should avoid both -q and -s and should redirect standard and error output to /dev/null instead. (-s is specified by POSIX.)
$ grep nonexistent_file something
grep: something: No such file or directory
$ grep nonexistent_file something -s
References
반응형
'IT이야기' 카테고리의 다른 글
Dell P2415Q 모니터와 맥북 연결 젠더 찾는 중 (2) | 2018.01.23 |
---|---|
진행중 - iCloud 저장공간 부족 AS 받는중. Documents 영역이 99% 차지하는 현상 (0) | 2018.01.23 |
osx - How to install wireshark on osx by homebrew (0) | 2018.01.23 |
osx - iterm, zsh, oh my zsh, agnoster 테마 적용 (0) | 2017.12.12 |
osx - 트랙패드 더블터치로 드래그 락 걸기 (0) | 2017.12.12 |
Comments