码迷,mamicode.com
首页 > 系统相关 > 详细

自学linux指令分析-find

时间:2017-04-12 03:02:21      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:vim   install   images   style   logs   time   nbsp   命令   file   

自学linux指令分析-find

 

1·命令格式

find pathname -options [-print -exec -ok ...]

find / -type f -name "freedom"

2·命令参数

-print                                        将查找到的文件输出到标准输出

-exec   command   {} \;              将查到的文件执行command操作,{} 和 \;之间有空格

-ok                                            和-exec相同,只不过在操作前要询用户

-name                                       接“文件名字”查找

-mtime +4                                 4天之前

-mtime -4                                  4天之内

-mtime 4                                   第4天

技术分享

 

 3、命令功能

 用于查找文件,并作出相应的处理

 

4、命令范列

[root@ban ~]# find / type f -mtime +5  找出5天前的使用记录

 [root@ban ~]# find /root/ -type f -mtime +5  找出/root/目录下5天前改过的文件全部找出来

/root/.bash_logout

/root/.cshrc

/root/.tcshrc

/root/.bash_profile

/root/anaconda-ks.cfg

/root/install.log.syslog

/root/install.log

/root/.viminfo

[root@ban ~]# find /root/ -type f -mtime -5 找出在/root/目录下最近5天改过的文件全部找出来

/root/.bash_history

 

[root@ban ~]# find  /root/  -type f     -name "*.log"          -mtime  +5  

                       指令  目录   类型文件  名字“*代表所有.log”     修改时间 +5代表5天之前

[root@ban ~]# find  /root/  -type f     -name "*.log"          -mtime     

                       指令  目录   类型文件  名字“*代表所有.log”     修改时间 5代表之前第5天

[root@ban ~]# find /root/ -type f -name "*.log"  -mtime +5|xargs rm –f 删除5天前的过期后缀名为log的文件

自学linux指令分析-find

标签:vim   install   images   style   logs   time   nbsp   命令   file   

原文地址:http://www.cnblogs.com/linuxfreedom/p/6696734.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!