Linux find command - find files modified recently

I don't write about Unix and Linux very much on this website, but when I just used a Linux find command to find files that had been modified in the last seven days, a friend said I should write a quick blog post about it.

Finding a file that has been modified in X days

Here's a simple Linux find command that shows how to find a file or directory that has been modified in the last seven days:

find . -mtime -7

This find command searches within the current directory (designated by the first ".") for all files and directories that have been modified in the last seven days.

As slight variations of that command, here's how you search for just files that have been modified in the last seven days:

find . -mtime -7 -type -f

and here's how you search for just directories that have been modified in the last seven days:

find . -mtime -7 -type -d

As one final variation of this find command, let's assume you want to search the "/tmp" directory instead of the current directory for files modified in the last three days:

find /tmp -mtime -3 -type -d

Linux find command with mtime - Summary

I hope these find command examples showing how to use the 'mtime' option have been helpful. As you can see from all of the examples I've shared, the find command is a powerful command for searching for and finding files and directories, with an incredible number of options.