conditional binary operator expected in shell script

Problem is in your if [[...]] expression where you are using 2 grep commands without using command substitution i.e. $(grep 'pattern' file).

However instead of:

if [[ grep $check_val1 $log -ne $check_val1 || grep $check_val2 $log -ne $check_val2 ]]; then

You can use grep -q:

if grep -q -e "$check_val1" -e "$check_val2" "$log"; then

As per man grep:

-q, --quiet, --silent
         Quiet mode: suppress normal output.  grep will only search a file until a match 
         has been found, making searches potentially less expensive.

Leave a Comment