1

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.

4

1 回答 1

6

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.

于 2013-08-29T19:40:32.823 回答