I am busy writing a bash script that can delete a file according to the date in a file name for example xxxxxxxxx140516.log. It should delete the file a day after the 16 of May 2014. I would like the script to read the file from character 25 because this is were the date start and it should do regular checks to see if there are any old files. Current my script looks like this:
#!/bin/bash
rm *$(date -d "-1 day" +"%y%m%d")*
The problem with this script is that if the computer is not up and running for a couple of days it will not delete old files that is past the date and it does not start on character 25. Please help, Thanks
*with.logto avoid accidental deletion of files that have the same date string somewhere in the xxxxxx too.