You need backquotes to capture output
Then double quotes to make it a single argument for test
And you need test
And it should be a truely empty string
Code:
if test "`cat /var/log/messages | grep fail`" = ""
then
echo "Good"
else
echo "Bad"
fi
alternatively use
Code:
if test -z "`cat /var/log/messages | grep fail`"
...
But you could get rid of all the above with
Code:
if grep fail /var/log/messages
then
echo failed
else
echo no problems
fi