You can use
find . -name 'a' -ctime 6 | xargs grep -l 'JMS111'
-ctime 6 looks for any file that's 6 days old. It actually compares the creation date of the file to the 24 hour period that's between 6*24 hours an 7*24 hours prior to your running the command. If the creation date is in that period, and the filename is 'a1', 'a2', or 'a3', then
find prints the path of that file. Since the period specified by -ctime <n> is based on when you ran the find command, you will have to use a different value for <n> if you run find tomorrow, than if you run it today.
Note: If you use
-ctime -6, find will print filenames that are 6 or fewer days old,
-ctime +6 will print file names that are 6 days or older. Also, some versions of find will allow you to specify units of measurement, e.g 6h, for 6 hours old.
You could instead use
-mtime if you want to search on modification time instead of creation time.
xargs makes it easy to check if you are getting the correct list of file from find before doing the
grep. Also, if you put grep in a
-exec primary, find invokes it once for each file it finds, whereas,
xargs receives a list of files that it passes to a single invocation of
grep, which is less resource intensive.
One disadvantage of
-ctime is you have to calculate the number of days since the file was created, but you can figure that out by running
find . -ctime n | xargs ls -l
until you see files with the date you're interested in.
... And, you don't have to remember to delete the bracketing files like you do with