0

Can someone let me know how to use command line to find files systemwide (from root) that are created within a specific date range?

Many thanks

  • Please search the site before asking such basic questions. This goes for those that answered as well as the OP! I found this one by looking for "file find date range" and sorting by votes. – slm Dec 30 '13 at 18:03

2 Answers2

1

If you are in GNU/Linux, something like this should do it, for example:

find / -newerct 20130409 ! -newerct 20140509

In BSD systems you can do something like this for the same effect:

touch -t 201304090000 /tmp/mark.start
touch -t 201405090000 /tmp/mark.end
find / -newer /tmp/mark.start ! -newer /tmp/mark.end

I think this will work in Solaris too but I cannot test it right now.

janos
  • 11,341
1

Would you believe with the find command?

The standard version of find only supports timestamps relative to some datum - either an existing file or an offset relative to 'now', but if you do want to find files with timestamps explicitly between 2 datums then you can create files with those timestamps using touch, then...

 touch -t 20131120000000 /tmp/fromdate
 touch -t 20131221000000 /tmp/todate
 find / -type f -newer /tmp/fromdate ! -newer /tmp/todate -exec ls -l {}\;
terdon
  • 242,166
symcbean
  • 5,540