標準出力とエラー廃棄

標準出力とエラー廃棄

以下を使用して出力をリダイレクトしました。/dev/空bashスクリプトではまだエラーが発生します。コードは以下のように表示されます。

ps -p $proc | fgrep $proc> /dev/null
if [ $? -ne '0' ] ; then
......
fi    

以下はエラーです

error: list of process IDs must follow -p

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).
Usage: fgrep [OPTION]... PATTERN [FILE]...
Try 'fgrep --help' for more information.

影響を与えずにこのエラーを抑制するにはどうすればよいですか?$?出力?

ベストアンサー1

&> /dev/nullstderrそしてを捨てなさいstdout。他のすべての人と同じ答えで、数文字だけ短くなります。

おすすめ記事