Conditional binary operator expected Error

Hi,

Below is my code where i m trying to grep for name>$servername in manages*.tmp files

        
       servername="serv1"
       set manages*.tmp
        if [ grep "name>$servername" $1 ]; then
    

However, i get the below error at the if condition:

Can you please suggest how can i fix the problem.

Hi,
Commands work with

if

without mediation of "test" (brackets []):

if grep "name>$servername" $1; then

The return code is enough for "if".

Also:

if [ $? -eq 0 ]; then

...is equivalent to

if test $? -eq 0; then

Regards!

Thank you !! it helped.

I am happy that it was useful.

Greetings!