Using find <directory> -mtime
would be a better idea then using the -ctime test, in the case where you may have moved the files to another directory or filesystem.
If you are storing them in a filesystem where -mtime doesn't work, there is still a problem with your general idea of extracting the day from the filename, and simply subtracting 5 from it. What if the backup was performed on the 3rd of the month?
However, to answer your general question about extracting information from the filename:
fn=$("date +%m%d%Y%T")
echo $fn
0128200607:17:55
> day=${fn:2:2}
> echo ${day}
28
>echo $(( ${fn:2:2} - 5 ))
23
The $(( )) means that this is an arithmetic expression. This way the substraction is carried out.
Compare with:
> echo ${fn:2:2} - 5
28 - 5
Here, the expression is a string of characters.
You probably need to write a bash function that will take the filename and return age of the file.
The date command is very interesting, and the coreutils manual has some interesting examples, such as:
date --date='5 days ago'
I would recomend that you read the "coreutils" manual and the "Finding Files" manual.
http://www.gnu.org/software/findutil...find.html#Time
http://www.gnu.org/software/coreutil...ate-invocation