find使用
find命令的主要作用是对树形目录层次结构进行彻底检查。
find命令的一般格式:
find pathname -expressions
find常用表达式
![](https://img2018.cnblogs.com/blog/1526080/201812/1526080-20181210152519246-1935886911.png)
在当前文件夹中找出名为.bak的文件,并将其删除;在删除过程中打印删除的文件名
![](https://img2018.cnblogs.com/blog/1526080/201812/1526080-20181210152557620-1993753560.png)
逻辑表达式
![](https://img2018.cnblogs.com/blog/1526080/201812/1526080-20181210152650753-919949878.png)
find示例
找出当前文件夹中,最近四天修改过的文件
find . -type f -mtime -4 -print
找出当前文件夹中,四天前修改过的文件
find . -type f -mtime +4 -print
找出当前文件夹中大于5000k的文件,并详细显示出来
find . -size +5000k -exec ls -lh {} \;
![](https://img2018.cnblogs.com/blog/1526080/201812/1526080-20181210152831233-1820887694.png)
注意:要用空格隔开
思考:
![](https://img2018.cnblogs.com/blog/1526080/201812/1526080-20181210152926811-3726108.png)
find /etc -type f -exec grep -il "telnet" {} \; | wc -l