Descomprimir archivos en bucle

Descomprimir archivos en bucle

Tengo el siguiente código que extrae números de archivos netcdf y cada bucle los coloca en otro archivo netcdf.

mapfile Latitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLatitude.txt) #tr is transform from to -s is squeeze. So look in the text files for all the spaces and replace them by newline '/n'
mapfile Longitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLongitude.txt)

echo "length of Lat is ${#Latitude[@]}"
echo "length of Lon is ${#Longitude[@]}"

outputNumber="$(ls -lq *_??????.nc | wc -l)"

echo "the number of output netcdf fles is ${outputNumber}"

valueI=`cat I.txt`
valueJ=`cat J.txt`
arrI=($valueI)
arrJ=($valueJ)

for ((i=1; i<=outputNumber; i++)) 
do
        echo "geknoei$i.nc"
        ncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.nc 

done

Por problemas de espacio, tuve que comprimir los archivos de entrada y este código ya no funciona. Me preguntaba si podría crear un código que en un bucle descomprima un archivo (uno a la vez), extraiga lo que necesito y luego lo vuelva a comprimir al final del bucle.

Entonces algo como esto:

mapfile Latitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLatitude.txt) #tr is transform from to -s is search. So look in the text files for all the spaces and replace them by newline '/n'
    mapfile Longitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLongitude.txt)

echo "length of Lat is ${#Latitude[@]}"
echo "length of Lon is ${#Longitude[@]}"

outputNumber="$(ls -lq *_??????.nc | wc -l)"

echo "the number of output netcdf fles is ${outputNumber}"

valueI=`cat I.txt`
valueJ=`cat J.txt`
arrI=($valueI)
arrJ=($valueJ)

for ((i=1; i<=outputNumber; i++)) 
do
        echo "geknoei$i.nc"
        gunzip *_??????.nc.gz
        ncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.nc
        gzip *_??????.nc 

done

El problema es que esto descomprime todos los archivos a la vez, lo que ocupará mucho espacio. Si descomprimo un archivo a la vez, mi código ncrcat ya no funcionará, ya que se extrae de todos los archivos .nc descomprimidos disponibles.

¿Cómo descomprimo un archivo .nc a la vez mientras sigo haciendo que la línea ncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.ncfuncione?

información relacionada