Shell Scripting: To check if a string is present in a command output
by rajesh[ Edit ] 2013-07-25 09:26:03
Here is an example method to find is a string is present in a output of a command thats executed inside a shell script.
cmd=`your command goes here`
echo "$cmd" | grep 'search string goes here' &> /dev/null
if [ $? == 0 ]; then
echo "string in output"
fi
replace
"your command goes here" with your command
"search string goes here" with the string to search