title: compare file names between directory and array
body: <p>I'm trying to create a script for running two different commands according to the names of the files in a directory.</p>
  
  <p>So far I created this small script:</p>
  
  <pre><code>#!/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
  </code></pre>
  
  <p>I'm trying to get all the files that end in <code>.nc</code>, then check if they are named different to the names in the <code>sumas</code> array. </p>
  
  <p>For the files that are named the same, a command will run: <code>cdo daymean input output</code> and the output file will have the same name as the input but with a <code>_d.nc</code> at the end (still have to remove the .nc of the input so they won't end up as <code>.nc_d.nc</code>).</p>
  
  <p>If their names are different to <code>sumas</code> then another command will run, with a similar syntax as the previous.</p>
  
  <p>I though the script was ready but I'm getting this error: 
  <code>scriptCDO.sh: 4: scriptCDO.sh: Syntax error: "(" unexpected</code></p>
  
  <p>Any idea of what is happening?</p>