0

So I am not used to shell scripting. I have a ksh script that has an if coniditon similar to below.

if [[ "asdasd" -eq "asdas()d" ]]; then

However when this runs it complains that

./closedown[36]: asdas()d: unexpected `('

I tried escaping it as such

if [[ "asdasd" -eq "asdas\(\)d" ]]; then

But then it complains about

./closedown[36]: asdas\(\)d: unexpected `\'

Hoping someone can help me out here, cheers

2 Answers 2

4

-eq is for numeral comparison and needs numbers on both sides.

Sign up to request clarification or add additional context in comments.

1 Comment

And use = or == instead.
0

In addition to the above comments about using '=' for text comparison as against '-eq' (which is for numerical comparison), double quotes allows shell to try and interpret what you have passed to the if condition.

Change that to use single-quotes - like so:

root@bumblebee> [[ 'asdasd' = 'asdas()d' ]] && echo 'Hello:)' || echo 'World:('
World:(

root@bumblebee>

Comments

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.