title: How can I find and delete files based on date in a linux shell script without find?
body: <p><strong>PLEASE NOTE THAT I CANNOT USE 'find' IN THE TARGET ENVIRONMENT</strong></p>
  
  <p>I need to delete all files more than 7 days old in a linux shell script. SOmething like:</p>
  
  <pre><code>FILES=./path/to/dir
  for f in $FILES
  do
    echo "Processing $f file..."
    # take action on each file. $f store current file name
    # perhaps stat each file to get the last modified date and then delete files with date older than today -7 days.
  
  done
  </code></pre>
  
  <p>Can I use 'stat' to do this? I was trying to use </p>
  
  <pre><code>find *.gz -mtime +7 -delete
  </code></pre>
  
  <p>but discovered that I cannot use find on the target system (there is no permission for the cron user and this can't be changed). Target system is Redhat Enterprise.</p>
  
  <p>The file names are formatted like this:</p>
  
  <p>gzip > /mnt/target03/rest-of-path/web/backups/DATABASENAME_<code>date "+%Y-%m-%d"</code>.gz</p>