In bash, [[ is syntactically a command which is terminated with the matching ]]. It is not part of the syntax of the if command, whose syntax starts:
if commands ; then
If you want to test whether a command succeeded or not, you just do that:
if grep -q pattern file; then
# grep found pattern in file
else
# grep did not find pattern in file
fi
Within a [[ command, bash expects to find a conditional expression, not another command. That's why grep -x ... is a syntax error. -x is a unary operator in a conditional expression, which is true if its argument is the name of an executable file, but in that expression it is being used as though it were a binary operator.
If you wish to test for more than one pattern with grep, you can use the -e option to specify each option; the grep will succeed (or select) lines matching any of the options:
if grep -q -e pattern1 -e pattern2 file; then
# grep found pattern1 or pattern2 in file
else
# grep did not find either pattern in file
fi
grep -x $idleis going to be reading from./Event.log? What do you wantgrep -x $idle1to read from?$idleand$deadcontain exacty the same string,grep -x $idle | grep -x $deadwill never return a match.-x, the entire input line must match. The output from the code mentions different "events" (in a way which suggests they are actually services or similar) so it seems highly unlikely that you need three different regexes to find one of them.