Monday, February 23, 2009

finding files by timestamp

Ex: to find all the files modified within the last 2 days. a day in this case is a 24 hour period relative to the current date and time. Note that you would use
-atime if you wanted files based on access time rather than modification time.

find . -mtime -2 -type f -exec ls -l '{}' \;

Ex: adding the daystart option means that we want to consider days as calendar days, starting at midnight

find . -daystart -mtime -2 -type f -exec ls -l '{}' \;

Ex: to find files modified between 1 hour and 10 hours ago

find . -mmin -600 -mmin +60 -type f -exec ls -l '{}' \;


Listing Newest Files First


Use the `−t' option with ls to sort a directory listing so that the newest files are listed first.

• To list all of the files in the `/usr/tmp' directory sorted with newest first, type:
$ ls −t /usr/tmp RET

No comments:

Post a Comment