2

i am fixing a given shell script and i am getting following error message

line 322: [: ==: unary operator expected

this error is returned from this line.

 if [ $4 == "managed?.out" ];then

could someone explain me what makes this error

Also could someone explain what is the purpose of using ? in the"managed?.out"

thanks in advance for any help

3 Answers 3

5

You need to quote $4:

if [ "$4" == "managed?.out" ];then
Sign up to request clarification or add additional context in comments.

2 Comments

Could you explain why exactly you need to do this? @codaddict
Yes, I'd be interested in the answer to @H_7's question as well.
1

change the if statement to

if [ "$4" == "managed?.out" ];then

The double-quotes are only necessary as you use $4, if your variable would be $string, you would not need them.

should "?" be interpreted as a bash-wildcard? if yes, you need to use

if [[ "$4" == managed?.out ]];then

Comments

0

try:

if [[ $4 == "managed?.out" ]];then

1 Comment

this is a separate question. what is the purpose of using ? sign in the managed?.out text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.