一些常见的Find 命令

来源:互联网 发布:java md5解密算法 编辑:程序博客网 时间:2024/05/18 20:47

1.查找当前目录下, 不超过3层文件夹里的txt 文件

find . -maxdepth 3 -name "*.txt" -print

2.查找当前目录下,不超过3层文件夹里的文件属主是gateman的txt 文件

find . -maxdepth 3 -name "*.txt" -user gateman -print

3. 查找当前目录下, 修改时间在1天内的文件.

find . -mtime -1 -type f -print

4. 查找当前目录下, 修改时间在5分钟以内的文件.

find . -mmin -5 -type f -print

如果你刚犯了一个错误但不确定会影响到那些文件,这很简单可以使用如下查询:find -mmin -5

如果一些系统find 没有 -mmin参数, 就先touch 1个文件tt.txt  然后 find . -newer tt.txt

5. 查找当前目录下, 查找文件属主是gateman的cpp 文件并以ls方式显示出来.

find . -user gateman -name "*.cpp" -ls

6. 查找当前目录下,所有tmp文件并删除

find . -name "*.tmp" -exec rm -rf {} \;

7. 查找当前目录下,所有txt文件并把结果放入./log/log1.txt中(覆盖)

find . -name "*.txt" > ./log/log1.txt


待补充。。

原创粉丝点击