🖥

Linux / Unix | Discard standard error

2019/04/16に公開

OK next.

 [command] 2>/dev/null 

in this case.

Because only the standard error output is discarded. Standard output can be used as it is.

Example

For example, if you want to find a specific file.

If you type a command normally. You will be warned a lot about directories that you don't have permission to.

 find / -name example.txt find: `/etc/directory1': Permission denied find: `/etc/directory2': Permission denied find: `/etc/directory3': Permission denied find: `/etc/directory4': Permission denied find: `/etc/directory5': Permission denied 

If you discard the standard error output, you get only the results you want.

 find / -name example.txt 2>/dev/null /tmp/example.txt /var/example.txt 

reference

Original by

Linux / Unix | 標準エラー出力を捨てる

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-04-16

Discussion