I am trying to do an IF statement from the output of an executed commmand. Here is how I am trying to do it, but it doesn't work. Does anyone know the right way to do this?
if [ "`netstat -lnp | grep ':8080'`" == *java* ]; then
echo "Found a Tomcat!"
fi
EDIT: I wonder if there is a way to do it by capturing exit code?
[
utility. The currently accepted answer captures the exit code of[[
, and the other answer captures the exit code of thegrep -q
pipeline.