Home > OS >  How to resolve this Syntax Error '(' unexpected in unix?
How to resolve this Syntax Error '(' unexpected in unix?

Time:10-21

#!/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?

CodePudding user response:

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.

  • Related