I'm trying to create a script for running two different commands according to the names of the files in a directory.
So far I created this small script:
#!/bin/bash
declare -a sumas=("CPRAT1sfc.nc" "CPRAT2sfc.nc" "CPRATsfc.nc")
for files in *.nc; do
    if [ "$files"="${sumas[@]}" ]; then
        cdo daymean $files {$files}_d.nc
    else
        cdo daysum $files {$files}_d.nc
    fi
done
I'm trying to get all the files that end in .nc, then check if they are named different to the names in the sumas array. 
For the files that are named the same, a command will run: cdo daymean input output and the output file will have the same name as the input but with a _d.nc at the end (still have to remove the .nc of the input so they won't end up as .nc_d.nc).
If their names are different to sumas then another command will run, with a similar syntax as the previous.
I though the script was ready but I'm getting this error: 
scriptCDO.sh: 4: scriptCDO.sh: Syntax error: "(" unexpected
Any idea of what is happening?
 
    