bash: testing conditions using if-grep


this expr can be really useful to determine if a term has been found or not using grep. short and sweet enough for me.

if [ ! -z $(echo $var | grep “cond”) ]; then echo “found”; else echo ” not found”; fi

Like it.? Share it:
Tags:

Comments are closed.