diaplaying the grep result

Hi,
My code is like this

if swlist -a revision 2>/dev/null | grep ABC 2>/dev/null  
then
		
     echo "Found  Above mentioned ABC Version, please remove it first..." 
fi
     

This is displaying the result to the screen.

i want to first suppress that and for that i wrote the below code

if swlist -a revision 2>/dev/null | grep ABC 2>/dev/null  > /dev/null
then
	$temp=swlist -a revision 2>/dev/null | grep ABC 2>/dev/null  	
     echo "Found  $temp ABC Version, please remove it first..." 
fi

But it is not working .... can any one help me???

Thanks

The syntax of the assignment is all wrong. But you can avoid running the thing twice. This is one of the few situations where really you want to execute a command first, and then examine its exit code in $?

temp=`swlist -a revision 2>/dev/null | grep ABC` # note backticks, not regular quotes
case $? in 0) # grep succeeded, meaning it was found
    echo Found $temp ABC version, please remove it first ... >&2 ;;
esac

I took the liberty of removing the 2>/dev/null from grep, because I don't see how it could produce an error.