In this article, We will see how find search the files based modification time criteria, say files modified in the last k mins or k hours or k days. This can be done with the find command options available. Before you start this article please go through the following article Basics of FIND Command In Unix/Linux for basics if you have already not followed.
SYNTAX:
find <path> -mtime +/-[Number Of Days]
-(Minus) Looks inside the window (0<Number Of Days)
+(Plus) Looks Outside the window (Number Of Days>)
Files modified in last 10 days.
$ find . -mtime -10
Output: Will return all the files which are modified in last 10 days.
Files modified before 10 days, means not modified in last 10 days.
$ find . -mtime +10
Output: Will return all the files which are modified 20 days before.
To find all the files which are MODIFIED before 10 days and less than 20 days
$ find . -mtime +10 –mtime -20
Output: Will return files which are modified in the window of 10 to 20
To find all the files which are MODIFIED before 30 days and less than 10 days
$ find . -mtime +30 –mtime -10
Output: Will not return anything because find can not find this criteria that file that are modified before 30 days AND in last 10 days.
Till Here We have Seen files modified in days, we can also find out files modified in minutes and hours.
To find all the files which are MODIFIED in last 10 minutes.
$ find . -mmin -10
To find all the files which are MODIFIED in before 10 minutes.
$ find . -mmin +10
find <path> -mtime +/-[Number Of Days]
-(Minus) Looks inside the window (0<Number Of Days)
+(Plus) Looks Outside the window (Number Of Days>)
Files modified in last 10 days.
$ find . -mtime -10
Output: Will return all the files which are modified in last 10 days.
Files modified before 10 days, means not modified in last 10 days.
$ find . -mtime +10
Output: Will return all the files which are modified 20 days before.
To find all the files which are MODIFIED before 10 days and less than 20 days
$ find . -mtime +10 –mtime -20
Output: Will return files which are modified in the window of 10 to 20
To find all the files which are MODIFIED before 30 days and less than 10 days
$ find . -mtime +30 –mtime -10
Output: Will not return anything because find can not find this criteria that file that are modified before 30 days AND in last 10 days.
Till Here We have Seen files modified in days, we can also find out files modified in minutes and hours.
To find all the files which are MODIFIED in last 10 minutes.
$ find . -mmin -10
To find all the files which are MODIFIED in before 10 minutes.
$ find . -mmin +10
To find all the files which are MODIFIED before 10 mins and less than 20 mins
$ find . -mmin +10 –mmin -20
No comments:
Post a Comment