Bash: regexp

example:

I have the following files and i want to change the day of the date:

totalacc.US.2012-10-09.txt
totalacc.US.2012-10-10.txt
totalacc.US.2012-10-11.txt
totalacc.US.2012-10-12.txt
totalacc.US.2012-10-13.txt
totalacc.US.2012-10-14.txt
totalacc.US.2012-10-15.txt
totalacc.US.2012-10-16.txt
totalacc.US.2012-10-17.txt
totalacc.US.2012-10-18.txt
totalacc.US.2012-10-19.txt
totalacc.US.2012-10-20.txt
totalacc.US.2012-10-21.txt
totalacc.US.2012-10-22.txt
totalacc.US.2012-10-23.txt

script:

#!/bin/bash
regex="((2012-[019]{2}-)([0-9]{1,2}))"
for name in `ls -1|sort |egrep -e «totalacc.US.2012-[019]{2}- .*»`
do
[[ $name =~ $regex ]]
day=«${BASH_REMATCH[3]}»
echo $day
done