Subtracting a date based on ls output

I am trying to achieve to get only the month and the day. Example Feb 5 (as you can see if it is feb 1-9) the space is 2. If it is feb 10-28, the space is only 1. I am trying to right a script that will list a directory and shoot an email if there is an activity in last 7 days. I dont really trust this command "find . -type f -mtime +7" . That is why i wanted to create a script

 date --date="30 days ago"
Sun Feb  5 16:01:34 UTC 2017

ONE=15
date1=`date`
TODAY=`date -d "$date1 - $ONE"  +%b %d`
ls -l |grep '$TODAY'

My desired output ( if fall between 1-9) -double space.

Feb  5

Hi,

Before continuing with addressing your scripting question, can I ask what it is about the use of find in this situation that puts you off using it ? The -mtime flag was literally made for exactly this kind of situation, and I've never found it to be un-reliable myself in any scenario where I've had to deploy it. For example, I regularly use it in scripts that prune backups older than a certain age.

It will of course only pick up on files that have been modified or created within that time-frame rather than accessed, but then that's exactly what you'd see in the output of ls as well, so there doesn't seem to be any advantage to writing your own solution here that I can see.

find . -type f -mtime +7 -exec ls -l {} \; 

Is that command really accurate? can it really list files on last 7 days?
Thanks

Hi,

The command:

find . -type f -mtime +7 -exec ls -l {} \;

will find all files underneath the current working directory that were last modified more than seven days ago and perform a long directory listing on them. So if that's what you're wanting, then this should absolutely do what you need.

Yes, but i want the files created in last 5 days..or 7 days..but that command will give you all the output een more than 7 days..it will give you the output last 100 days or 200... that is why im gonan create a script to give me the files...exactly last 7 days..example..from march1 2 3 4 5 6 7.. it will not include feb28 feb27 etc..

Try -mtime -7 .