How to find the list of files modified in the last 30 minutes in Linux? Learn how to find files modified in last 5 minutes Linux or find files modified in last 2 days Linux.
Using find Command
The ‘find’ command searches the directory tree rooted at each file name FILE by evaluating the EXPRESSION provided. This list of files to search is followed by a list of expressions
describing the files we wish to search for.
find [path] -type f -mmin n
NOTE: The n indicates the time in minutes – how many minutes you want to find files for. The following command options are used:
- -n will find the files which have been modified in less than n minutes (- is for more/decreasing order)
- +n will find the files which have been modified in more than n minutes (+ is for more/increasing order)
- n will find the files which have been modified in exacly specific n minutes
Finding files modified in the last 5 minutes
The following fin command will find all the files that have been modified in the last ten minutes. Note that unless path is specified, it will find files in the current directory.
find . -type f -mmin -10
Finding files modified in the last n days
We use -mtime instead of -mmin to find modified files in the last n days instead of n minutes. For example, to find files that have been modified in the last 3 day in Downloads folder, the following command will be used:
find /Downloads -type f -mtime -3 -ls
Similarly, if you want to find modified directories in the last n minutes or days, just change -type f with -type d. The d is for directories whereas the f is for files.