Home > Software engineering >  How to exclude error mesage from bash string
How to exclude error mesage from bash string

Time:12-14

I have command in my xubuntu:

nvidia-settings -q gpucoretemp | grep '(user-xubuntu:0.0):' | sed 's/^.*: //'

And I have the result:

libEGL warning: DRI2: failed to authenticate
46.

If I try to exclude 'libEGL warning: DRI2: failed to authenticate' :

nvidia-settings -q gpucoretemp | grep -v 'libEGL warning: DRI2: failed to authenticate' | grep '(user-xubuntu:0.0):' | sed 's/^.*: //'

The result is the same. How to ignore the 'libEGL warning: DRI2: failed to authenticate' string?

CodePudding user response:

You can first redirect stderr to stdout and then filter the result with grep.

nvidia-settings -q gpucoretemp 2>&1 | grep -v 'libEGL warning: DRI2: failed to authenticate' | grep '(user-xubuntu:0.0):' | sed 's/^.*: //'
  • Related