Hi everybody,

I'm sorry If I ask a silly question. I have a simple code like this

#!/bin/bash

verify()
{

    // do something
    return $(grep -q 'VERIFICATION SUCCESSFUL' result.txt)

}

if [ verify 'a Condition' ]; then

    echo debug

fi

I have the following error:

line x: [: verify: unary operator expected

Can anyone explain for me why I have this error, and how can I correct it?
Thanks in advance.

Hello Dark2Bright!

I'm not sure what you're trying to do with 'verify' in this case, but the 'verify' command seems to be pretty specific:

verify - Utility to verify certificates.

Are you trying to verify a certificate in this 'if' statement? If not, what condition are you testing?

Thanks!

Hi, thanks for your reply.
verify is a function I define for myself (you can see the code above), not a Unix command. I figure out the problem, I made it wrong, I should do like this:

if verify 'a Condition'; then

The script will run correctly.

Oh, I see... How did I miss that? Looks like I also missed that the 'verify' that I found was not a command, but an argument to 'openssl'... I'll go back to my corner now...

Thanks for the follow-up :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.