#!/bin/ksh
# Script para repetir comando com modificacao de data
#
# As Datas tem que ser informada
datai=2023021100
dataf=2023032418

###############################################################
#            INICIO DO LOOP PRINCIPAL                         #
###############################################################
echo "Espaço de disco antes do processamento"
du -sh .
data=$datai

while [ ${data} -le ${dataf} ]
do

  # Comando a ser executado
  echo "Processando a data: " ${data}
  du -sh ${data}.tgz
  tar -xzf ${data}.tgz
  rm -rf ${data}/RST

  ls ${data}/

  nfiles=`ls ${data} | wc -l`

  if [ $nfiles -lt 11 ];then
     echo "numero de arquivo dezipados com problema" $nfiles
     ls ${data}
  else
     echo "remove o tar"
     rm -rf ${data}.tgz
  fi

  # final do loop da rodada

  data=`caldate.3.0 $data + 6h 'yyyymmddhh'`

done

# final do loop da rodada

echo "Espaço de disco depois do processamento"
du -sh .

exit 0


