In this tutorial, you will learn how to use find command to locate files older than specific time in Linux.
In our previous guide, we learnt how to use find command to locate files newer than specific time in Linux.
The link is provided below;
Use find command to locate files newer than specific time in Linux
Use Find Command to locate files older than specific time in Linux
According to man pages, find command is used to search for files in a directory hierarchy.
The basic command line syntax for find
command is:
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]
Locate files Modified more than 30 days ago
To find files that were modified more than 30 days ago, run the following command
find . -type f -mtime +30 -print
Where:
find
– it’s the command namedot(.)
– means the current directory/folder. You can replace this with the absolute path of the file, for example,/var/log
.-type f
– means of type file-mtime
– older than the time input-print
– display the files
Locate files Modified more than 30 mins
To find files that were modified more than 30 minutes ago, run the following command
find . -type f -mmin +30 -print
Locate files Accessed more than 30 days ago
To find files that were accessed more than 30 days ago, run the following command
find . -type f -atime +30 -print
Locate files Accessed more than 30 minutes ago
To find files that were accessed more than 30 minutes ago, run the following command
find . -type f -amin +30 -print
Find files that were changed more than 60 days ago
To find files that were changed more than 60 days run the following command;
find . -type f -ctime +60 -print
Find files that were changed more than 60 minutes ago
To find files that were changed more than 60 minutes ago, run the following command;
find . -type f -cmin +60 -print
Find Files Modified between specific period of time
For example, to find files modified more than 30 days and not more than 1 year run the following command
find . -type f -mtime +30 -mtime -365 -print
For example, to find files modified more than 30 minutes and not more than 1 hour, run the following command
find . -type f -mmin +30 -mmin -60 -print
Find Files Accessed between specific period of time
For example, to find files accessed more than 30 days and not more than 1 year run the following command
find . -type f -atime +30 -atime -365 -print
For example, to find files accessed more than 30 minutes and not more than 60 minutes ago, run the following command
find . -type f -amin +30 -amin -60 -print
Find Files Changed between specific period of time
For example, to find files whose status was changed more than 30 days and not more than 1 year run the following command
find . -type f -ctime +30 -ctime -365 -print
For example, to find files whose status was changed more than 30 minutes and not more than 60 minutes ago, run the following command
find . -type f -cmin +30 -cmin -60 -print
Read more on:
man find
Other tutorials