In this article, We will see how find search the files based CHANGED criteria, say files CHANGED 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> -ctime +/-[Number Of Days]
-(Minus) Looks inside the window (0<Number Of Days)
+(Plus) Looks Outside the window (Number Of Days>)
Files CHANGED in last 10 days.
$ find . -ctime -10
Output: Will return all the files which are CHANGED in last 10days.
Files CHANGED before 10 days, means not CHANGED in last 10 days.
$ find . -ctime +10
Output: Will return all the files which are CHANGED 20 days before.
To find all the files which are CHANGED before 10 days and less than 20 days
$ find . -ctime +10 –ctime -20
Output: Will return files which are CHANGED in the window of 10 to 20
To find all the files which are CHANGED before 30 days and less than 10 days
$ find . -ctime +30 –ctime -
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 CHANGED in days, we can also find out files CHANGED in minutes and hours.
To find all the files which are CHANGED in last 10 minutes.
$ find . -cmin -10
To find all the files which are CHANGED in before 10 minutes.
$ find . -cmin -10
Note: If you observe only switch are changed in find command while searching for files based Access/Modification/Update. -atime is used for access and -mtime is used for modification and -ctime is used for change/update rest all the syntax is same.
No comments:
Post a Comment