[Reprint] find a command - to find the modified file find command within a specified time - to find the modified file within the specified time

find command - to find the modified file within the specified time

 
https://www.cnblogs.com/wangyao3568/p/7675891.html

 

For example, we want to look for changes made to files within a specified time under linux, we can use the find command, in fact, the function of the find command is very powerful, let's learn a few simple commands under find examples of simple use:

find / opt - iname "*" -atime 1 -type f
find / opt under previous day visited file
options oPTIONS
All options always return true, they will always be performed unless in the expression is unreachable place . Therefore, for clarity, it is best to put them in the beginning of the expression.

-daystart
beginning rather than from the previous 24 hours, the computation time (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) day from the start.

-amin n
last accessed the file is n minutes ago.

-anewer file
on a recent visit than the file modification time of the file to be late. If the command line -follow comes before -anewer, (only in this case it will be affected by -follow -anewer effect).

-atime n
Last Visit before the file is n * 24 hours.

-cmin n
recent changes to the file status is n minutes ago.

-cnewer file
File's status was last changed than the file modification time is later. If the command line -follow comes before -cnewer, (only in this case will be affected by -follow -cnewer effect).

-ctime n
File's status was last changed n * 24 hours before.

-mmin n
last modified recent data file is n minutes ago.

-mtime n
file data was last modified n * 24 is before the hour.

-mtime: Specifies the time has been changed files, meaning that the file contents are changed

-ctime: Specifies the time the file was changed, meaning that the file permissions are changed

-atime: specified time once accessed the file , meaning that the file has been read
1. the time is 24 hours as a unit, rather than days
2. 2011/09/08 12:00 time to start looking, will be listed within 12 day 2011/09/07 : 00 ~ 2011/09/08 12:00 the time in the file


to find three days "before" being changed file (formerly → 2011/09/05 12:00 before the third previous file) (> 72 hours )

find / var / log / F -type -mtime +3 -print  
identify three days is changed files (files within 2011/09/05 12:00 ~ 12:00 2011/09/08) (0 ~ 72 hours)

find / var / log / -mtime -3   -type f -print
3 days prior to find out the changed files (files within 2011/09/04 12:00 - 2011/09/05 12:00) (72 to 96 hours)

find / var / log / F -type -print -mtime. 3  
to find the first three days was changed files (also write)

find / var / log / -mtime +2 -4 -type -mtime f -print   
      append a command # stat, stat filename can view additional information about the file, including the time stamp, and so on ...

1 Delete 0 byte files
find . -type f -size 0 -exec rm -rf {} \; 
. Find -size type F 0 -delete

2.find command first matching all file named "passwd *" files, such as passwd, passwd.old, passwd.bak, filtered grep -exec;
[Home the root @ localhost] # the Find / etc -name "passwd *" -exec grep "wang" {} \;


3.find command to find the file in the current directory name ends with .log, change the time of the file before the 5th, and remove them, delete prior to prompt;
. [Home the root @ localhost] # Find -name "* .conf" +5 -OK RM -mtime {} \;
<... RM ./cmake-2.8.4/DartLocal.conf> ? NO


4. Find time for changes in the / logs directory in the previous 5 files and delete them:
[root @ localhost Home] # the Find / logs the -type f -exec -mtime +5 RM {} \;
 
For example, we want to look for changes made to files within a specified time under linux, we can use the find command, in fact, the function of the find command is very powerful, let's learn a few simple commands under find examples of simple use:

find / opt - iname "*" -atime 1 -type f
find / opt under previous day visited file
options oPTIONS
All options always return true, they will always be performed unless in the expression is unreachable place . Therefore, for clarity, it is best to put them in the beginning of the expression.

-daystart
beginning rather than from the previous 24 hours, the computation time (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) day from the start.

-amin n
last accessed the file is n minutes ago.

-anewer file
on a recent visit than the file modification time of the file to be late. If the command line -follow comes before -anewer, (only in this case it will be affected by -follow -anewer effect).

-atime n
Last Visit before the file is n * 24 hours.

-cmin n
recent changes to the file status is n minutes ago.

-cnewer file
File's status was last changed than the file modification time is later. If the command line -follow comes before -cnewer, (only in this case it will be affected by -follow -cnewer effect).

-ctime n
File's status was last changed before n * 24 hours.

-mmin n
last modified recent data file is n minutes ago.

-mtime n
file data was last modified n * 24 is before the hour.

-mtime: Specifies the time has been changed files, meaning that the file contents are changed

-ctime: Specifies the time the file was changed, meaning that the file permissions are changed

-atime: specified time once accessed the file , meaning that the file has been read
1. the time is 24 hours as a unit, rather than days
2. 2011/09/08 12:00 time to start looking, will be listed within 12 day 2011/09/07 : 00 ~ 2011/09/08 12:00 the time in the file


to find three days "before" being changed file (formerly → 2011/09/05 12:00 before the third previous file) (> 72 hours )

find / var / log / F -type -mtime +3 -print  
identify three days is changed files (files within 2011/09/05 12:00 ~ 12:00 2011/09/08) (0 ~ 72 hours)

find / var / log / F -type -mtime -3 -print  
3 days prior to find out the changed files (the 2011/09/04 12:00 ~ 12:00 2011/09/05 file) (72 to 96 hours)

Find / var / log / F -mtime. 3 -type -print  
Find the first three days of the changed file (also write)

the Find / var / log / -mtime +2 -4 -mtime The -type f -print   
      append a command # stat, stat filename can view additional on file information, including a time stamp, and so on ...

1 Delete 0 byte files
find . -type f -size 0 -exec rm -rf {} \; 
. Find -size type F 0 -delete

2.find command first matching all file named "passwd *" files, such as passwd, passwd.old, passwd.bak, filtered grep -exec;
[Home the root @ localhost] # the Find / etc -name "passwd *" -exec grep "wang" {} \;


3.find command to find the file in the current directory name ends with .log, change the time of the file before the 5th, and remove them, delete prior to prompt;
. [Home the root @ localhost] # Find -name "* .conf" +5 -OK RM -mtime {} \;
<... RM ./cmake-2.8.4/DartLocal.conf> ? NO


4. Find time for changes in the / logs directory in the previous 5 files and delete them:
[root @ localhost Home] # the Find / logs the -type f -exec -mtime +5 RM {} \;
 

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12465488.html