#!/bin/bash

# List all files matching the pattern
infiles=$(ls Q0_AFR-44_CNRM-CERFACS-CNRM-CM5_rcp85_r1i1p1_SMHI-RCA4_v1_day_*_daily_final.nc)

for f in $infiles; do
    # Create a new filename for the modified file
    newfile="${f%.nc}_EAF_S.nc"
    
    # Perform the operation and save the modified data into a new file
    cdo sellonlatbox,41,35,-2,-19 \
        $f $newfile
done
