0
#!/bin/ksh 
arr=(1 2 3 4 5);
echo "${arr[*]}"

The above script name is num.sh

I tried to execute this script by ./num.sh. But I got syntax error '(' unexpected

I don't know what is the issue in the above script. Can anyone help me to solve this?

0

1 Answer 1

1

That syntax arr=(1 2 3 4 5) might be unavailable in your version of korn-shell.

Check if ksh93 is available on your system and if so, then put that path at the first line of your script.

Otherwise when ksh93 is not available, use the old syntax set -A arr 1 2 3 4 5

Also, omit the trailing semicolon , which is only needed when you have multiple statements on the same line.

More details here.

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

2 Comments

Thanks mao. It works .
And I have one more doubt Can I able to use c like for loop in ksh? Like for ((expr1;expr2;expr3)) do #statement done

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.