find命令 — 之查找指定时间内修改过的文件
- font size decrease font size increase font size
- Print Email
find命令 -- 之查找指定时间内修改过的文件
比如我们要查找linux下指定时间内做过改动的文件,我们可以用find命令,其实find命令的功能十分强大,下面我们通过几个简单的例子来学习下find命令的简单用法:
find /opt -iname "*" -atime 1 -type f
找出 /opt 下一天前访问过的文件
选项 OPTIONS
所有的选项都总是返回真值,它们总会被执行,除非放在表达式中执行不到的地方。因此,清楚起见,最好把它们放在表达式的开头部分。
-daystart
从当日起始时开始而不是从24小时之前,计算时间(for -amin, -atime, -cmin, -ctime, -mmin, and -mtime)。
-amin n
对文件的最近一次访问是在 n 分钟之前。
-anewer file
对文件的最近一次访问比 file 修改时间要晚。如果命令行中 -follow 在 -anewer 之前,(也只有在这种情况下 -anewer会受 -follow 的影响)。
-atime n
对文件的最近一次访问是在 n*24 小时之前。
-cmin n
对文件状态的最近一次修改是在 n 分钟之前。
-cnewer file
对文件状态的最近一次修改比 file 修改时间要晚。如果命令行中 -follow 在 -cnewer 之前,(也只有在这种情况下-cnewer 会受 -follow 的影响)。
-ctime n
对文件状态的最近一次修改是在 n*24 小时之前。
-mmin n
对文件数据的最近一次修改是在 n 分钟之前。
-mtime n
对文件数据的最近一次修改是在 n*24 小时之前。
-mtime : 指定时间曾被改动过的文件,意思是文件內容被更改过
-ctime : 指定时间曾被更改过的文件,意思是文件权限被更改过
-atime : 指定时间曾被存取过的文件,意思是文件被读取过
1. 时间是以 24 小时为一个单位,而不是以天的
2. 2011/09/08 12:00 时间开始找一天內的,会列出 2011/09/07 12:00 ~ 2011/09/08 12:00 时间內的文件
找出 3 天"以前"被改动过的文件 (前第三天以前 → 2011/09/05 12:00 以前的文件) (> 72 小时)
- find /var/log/ -mtime +3 -type f -print
找出 3 天內被改动过的文件 (2011/09/05 12:00 ~ 2011/09/08 12:00 內的文件) (0 ~ 72 小时內)
- find /var/log/ -mtime -3 -type f -print
找出前第 3 天被改动过的文件 (2011/09/04 12:00 ~ 2011/09/05 12:00 內的文件) (72 ~ 96 小时)
- find /var/log/ -mtime 3 -type f -print
找出第 3 天被改动过的文件 (也可以这样写)
- find /var/log/ -mtime +2 -mtime -4 -type f -print
( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0008 | 403656 | {main}( ) | .../index.php:0 |
2 | 0.0541 | 1321728 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.0541 | 1321728 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.3454 | 2980128 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.3460 | 3004904 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.3467 | 3060232 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.3468 | 3077288 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.3530 | 3221376 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.3530 | 3221376 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.3585 | 3490456 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.3585 | 3490456 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.3598 | 3508976 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.3617 | 3529392 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.4073 | 4117464 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.4073 | 4117464 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.4096 | 4291864 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |
- Published in CentOS 6
- Read 2599 times
( ! ) Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0008 | 403656 | {main}( ) | .../index.php:0 |
2 | 0.0541 | 1321728 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.0541 | 1321728 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.3454 | 2980128 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.3460 | 3004904 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.3467 | 3060232 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.3468 | 3077288 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.3530 | 3221376 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.3530 | 3221376 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.3585 | 3490456 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.3585 | 3490456 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.3598 | 3508976 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.3617 | 3529392 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.4073 | 4117464 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.4073 | 4117464 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.4096 | 4291864 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |