0

please assist, I am trying to list the files from last 3 days in directory starting from midnight of first day from last 3-days. I created this so far " find ./* -type f -mtime -3 -exec ls {} ;" This only pulls data from current time to - 3days. It doesn't get data from midnight of first day. I need a data start from last 3-days starting midnight to today.

Please assist. thank you

oguz ismail
  • 1
  • 16
  • 47
  • 69
chand
  • 1
  • 1

1 Answers1

0

You can touch a file with the earliest date you want to use. Then use find's -newer option.

touch -t <earliestDate> someTempFile
find . -type f -newer someTempFile -exec ls -l {} \;

You don't need -exec if you execute ls with no options and you're constrained to normal files.

Jeff Holt
  • 2,940
  • 3
  • 22
  • 29
  • Thanks for the hint, i don't want to hardcode any date. Instead i would like to get data from last 3-days starting from the midnight of the first day that is 00:01 etc. please assist is there any way to creat the "someTempFile" with eralistDate starting from 00:00. – chand Dec 30 '20 at 14:40
  • Here is what i have done so far. # touch --date "-3 days" +'%Y-%m-%d %H:%M:%S' someTempFile # find stm* -type f -newer someTempFile -exec ls {} \; > ./myfiles.txt Output: -rw-rw-r--. 1 user1 user1 23 Dec 27 02:58 someTempFile Q: if created someTempFile file stamp will be 00:00 instead 02:58 will solve request. please assist. thanks – chand Dec 30 '20 at 14:51