The command
grep shutting log.log
returns nothing.
My script is as follows
#!/bin/bash
FAIL=`grep shutting log.log`
if [ "$FAIL"="Binary file log.log matches" ]; then
echo FOUND
else
echo NOT FOUND
fi
I’m expecting NOT FOUND but get FOUND
You have to put spaces around the
=operator in an[ ... ]expression; what you have written is being interpreted as[ string ], which tests whetherstringis nonempty.But you don’t need backticks nor string comparison at all here. Try this instead:
(Thankfully, the systems that did not have the
-qoption togrephave long since gone to the great bit bucket in the sky.)