首页 > 其他 > 详细

find命令

时间:2018-07-27 13:03:24      阅读:144      评论:0      收藏:0      [点我收藏+]
find命令:

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


find命令

原文:http://blog.51cto.com/12107790/2150952

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!