#!/bin/bash # search file names and rebuid # set up working years year=(1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000) # set the experinment name exp="BCLb" # set the file path for searching files in_dir_path="/ccc/store/cont003/dsm/p529luy/IGCM_OUT/LMDZOR/PROD/amip/"$exp"/ATM/Output/DA" #echo $in_dir_path # move the path to search the files cd $in_dir_path # start the loop for searching the files... for index in {0..19} do echo "Search files on year: ${year[$index]}" # use the "find" and "sort" command to find the files # and sort by the numberic number appears in the filenames inputfilename=( $(find -name "${exp}_${year[$index]}*" | sort -n) ) echo "PROCESSING input files: "${inputfilename[@]} # make a outout file name based on the working "exp" and "year" export outputfilename="${exp}_${year[$index]}.nc" # use "ncrcat" command to re-create(combine) the nc file based on the searched inputfilename ncrcat ${inputfilename[@]} /ccc/store/cont003/dsm/cheny/Daily/${exp}/$outputfilename echo "PLEASE CHECK output file: "$outputfilename done echo "FINISHed THE COMBINE files job.. (AH-JA...)"$outputfilename