search for files in a directory hierarchy
搜索指定目录中的文件
语法:
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]
find path -option [ -print ] [ -exec -ok command ] {} \;
常用选项:
-type指定需要查找的文件或目录。d f
-name 指定需要查找文件或目录名称
-mtime n +n表示在n天之前,-n表示在n天之内,n表示在第n天修改的文件
-size +/-n 大于或小于大小的文件或目录
-empty 查找空文件或目录
-perm 查找是属于多少权限的文件或目录
-iregex 可加正则
实例:
[root@www1 ~]# find -size 0
./1
./b
./ceshi/a
./python/test/__init__.py
./.elinks/socket0
./.elinks/bookmarks
[root@www1 ~]# find / -name "myfile.py"
/root/python/myfile.py
[root@www1 ~]# find -size 0 -exec rm -r {} \;
[root@www1 ~]# find -size 0
[root@www1 ~]#
[root@www1 ~]# find -type f -exec ls {} \;
[root@www1 ~]# find -type f |xargs ls
./1.log ./httpd-2.4.33.tar.gz ./python/__pycache__/third.cpython-36.pyc ./test666.txt
[root@www1 ~]# find -type f -mtime 3 |xargs ls原文:http://blog.51cto.com/12107790/2150952