I have netCDF files in two directories that I want to ultimately find a single variable in and compare, and if not equal I want to remove both files. What I have so far:
dir1=(/working/test/temp1/*.nc)
dir2=(/working/test/temp2/*.nc)
Here I'm trying to store the output of grep into an array. I found these methods on the site, but neither to work.
for ((i = 0; i < ${#dir1[@]}; ++i)); do
dir1_arr=($(ncdump -h "$dir1" | grep "Temperature = "))
done
for i in $dir1; do
dir1_arr=($(ncdump -h "$i" | grep "Granules = "))
done
I'm not sure if this is the right approach, but I want to then compare the granule values that should be stored in two separate arrays, then delete the corresponding files if the granules don't match. First I need to get past this step of storing the output of grep in array.
echo ${dir1[@]}, nothing prints to the screen.dir1array is empty. Is the directory you care about really the absolute path/working/...or should that just be the relative pathworking/...?echo "${dir1[@]}"work?