Chris
Chris

Reputation: 1697

Function failure - shell script converted from Bash to Korn

I wrote a shell script that does data manipulation on a server running bash shell.

My script has a function which retrieves data inside ZIP files

function getCTLfile() {
  for i in ${Array[@]}; do 
    if [[ `echo ${i}|awk -F . '{print $NF}'` == "ctl" ]]; then 
      echo "${i}" 
    fi
  done
}

It works great but this machine hardware is faulty so our sysadmin requested that I port my code to another server running Korn shell.

When I run my script, it fails on my function!! Even if I type it from the command line.

$ function getCTLfile() {
-ksh: syntax error: `(' unexpected

Do I need to change my syntax anywhere? I did some research and it seems that everything should work.

Upvotes: 1

Views: 392

Answers (1)

Emmet
Emmet

Reputation: 6421

The function declaration syntax in ksh either uses the function keyword or the parentheses, but not both. Leave out either the parentheses or the function keyword and it should work.

Upvotes: 6

Related Questions