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