grep -q VS. grep > /dev/null

Bryan O'Neal Bryan.ONeal at TheONealAndAssociates.com
Wed May 28 22:26:04 MST 2014


So I had a coworker ask me why I always do
echo $foo | grep $bar > /dev/null
if [[ $? -eq 0]] then; ....

Instead of just using greps quiet option. And I remember their being
some definite bug with -q and checking return codes but for the life
of me I can not recall it right now.  Just like I can not recall why I
use [[ ]] insted of just [ ]. Their was a reason I switched at some
point but can not recall what it is.
It could have been somthing  with egrep or using peal regex with grep
but honestly I can not recall...

Thus I am here to ask you, my fellow bash geeks, what what that reason!


More information about the PLUG-discuss mailing list