Stdout and stderror in CentOS

1

I am exec command:

yum info mcrypt | grep -i error > /dev/null
yum info mcrypt | grep -i error 2> /dev/null

But i see:

Error: No matching Packages to list

How I can hide this messasge from stdout?

Java Dude

Posted 2013-09-16T17:58:29.070

Reputation: 15

Answers

-4

nohup commands > /dev/null 2>&1 &

Java Dude

Posted 2013-09-16T17:58:29.070

Reputation: 15

Please explain how this solves your problem. – mveroone – 2013-11-26T08:40:15.587

1How is this related to the question? Yes you used 2>&1 as davidgo suggested two months ago. -- Combined in >/dev/null 2>&1 it will discard both stdout and stderr. ...but how is the nohup and background execution & related? – pabouk – 2013-11-26T08:43:33.143

3

Its not exactly clear what you are trying to do - Why would you "grep" for an error message you don't want.

I suspect the problem you are having may be that you are diverting stderr after it has been displayed - you may want to be using

yum info mcrypt 2>/dev/null | grep -i "error"

Or, if you are simply wanting to ignore the error,

yum info mcryp3t 2>/dev/null

davidgo

Posted 2013-09-16T17:58:29.070

Reputation: 49 152

Thank you so mach.

But it not what i want.

i am using this expression to check avebility of yum package in my bash script. – Java Dude – 2013-09-16T18:11:02.403

$(yum info mcrypt | grep -i error) 2> /dev/null the same – Java Dude – 2013-09-16T18:12:48.350

1how about 'yum info mcrypt 2>&1 | grep "Name"' or 'yum info mcrypt 2>&1 | grep "Name" | wc -l' – davidgo – 2013-09-16T18:16:51.527