自学linux指令分析-find

自学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的文件

posted @ 2017-04-11 22:28  极光无影_烽  阅读(161)  评论(0编辑  收藏  举报