[Linux](EN) Ignore stderr in terminal prompt using /dev/null and redirect

Redirect stderr to /dev/null so that ignore prints of standard errors in terminal prompt.


Environment and Prerequisite

  • Linux base system
  • Bash shell(/bin/bash)
  • Redirect


Terms

What is /dev/null?

  • /dev/null : Device file that discards all data written to it but reports that the write operation succeeded.
  • You can ignore standard error on screen when you write stderr to /dev/null.

What is redirect?

  • Redirect('>'): Redirect standard streams to user-specified locations like file or other stream.
  • Reference : Redirection (computing)


Usage example

Ignore stderr in find command

  • It prints Permission denied as stderr
$ find / | grep neutron
find: ‘/run/docker’: Permission denied
find: ‘/run/containerd’: Permission denied
find: ‘/run/lxcfs’: Permission denied
find: ‘/run/sudo’: Permission denied
find: ‘/run/log/journal/50739525d1fb4eac9e863478fb990fed’: Permission denied
find: ‘/run/lvm’: Permission denied
  • After redirect stderr to /dev/null, there is no Permission denied
  • 2 represents stderr
find / 2> /dev/null | grep neutron
/home/twpower/test/neutron_patched
/home/twpower/test/neutron_patched/LICENSE
/home/twpower/test/neutron_patched/.gitignore
/home/twpower/test/neutron_patched/bin
...


Reference

[Linux] vi(또는 vim)에서 문자열 치환하기

> vi 또는 vim에서 문자열들을 원하는 문자열로 바꿔보자.## 환경- Linux 기반 시스템- Bash shell(/bin/bash)- vi 또는 vim## vi(또는 vim) 문자열 치환### 기본형#### 형식```:%s/[원래문자열]/[...… Continue reading