Get list of modified files in directory

Here is a command to get a list of modified files in a directory and subdirectories;

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

This command searches all files in directory and subdirectories (the find . )

The command is going to list all files (the ls -l) a day old (the -mtime -1), where mtime is the modified time.

Possible time units are as follows:

  • s second
  • m minute (60 seconds)
  • h hour (60 minutes)
  • d day (24 hours)
  • w week (7 days)

Any number of units may be combined in the -mtime argument, for example, ‘-mtime -20d1h30m’ which can be altered to filter your search.

So if I wanted to get a directory of files that were initially modified say, 20 days ago but I knew I updated some of those files since. I use this command…

find . -type f -mtime -19d23h -exec ls -l {} \;

One thought on “Get list of modified files in directory

  1. afaik the second method depends on which version of find you are using (works with the version on your Mac, but perhaps not on your Linux 🙂 )

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s