# sample file
#datafiles-to-be-deleted-20201127.checked

source ~/.bashrc

# this script checks if there are scheduled deletion files generated by the checker
# sample usage: only the paths where are the files are needed
# ./schedule_free_space.sh /home/Earth/jberlin/Development/dqc_results/

source ~/.bashrc

# Filter
delete_data="false"
if [[ -z "$1" ]] ; then
    echo "No path supplied"
    exit 1
fi

# get the current date
current_date= echo $(date '+%Y%m%d')
scheduled_deletion_file=datafiles-to-be-deleted-${current_date}.checked

if [[ -f ${scheduled_deletion_file} ]] ; then
   # read the content of the file
   # secure that we are only deleting grib files
   while IFS= read -r line
   do
      echo "deleting ${line}"
   done < "${scheduled_deletion_file}"
else
  echo "nothing to delete"
fi