all,
I am checking the error info in a file in the last line, I would like to have a "yes" result if there is an "Error". My shell script is like below:
[ $(tail -1 error.log | grep -E "Error") ] && echo "yes"
then I got the error like above in the title:
-bash: [: @: binary operator expected
The error message in the last line is like below:
[aaa,bbb,ccc, Error.ddd @ ]
I think that is because of the the Error message, which has [ @ ] format content caused this error. But I do not know how to fix it. Is there any one knows how to process this [ @ ] problem. Thanks very much
@csiu, thanks very much for your quick reply.
The trick here is to use double "[" as below:
[[ $(tail -1 error.log | grep -E "Error") ]] && echo "yes"