linux find 命令实例

查找空目录
find /path -depth -type d -empty

查找空文件
find /path -depth -type f -empty

查找指定文件
find /path -name name_of_file

查找指定类型的文件
find /path -name “*.given_extension”

查找指定权限的txt文件
find /path -name ‘*.txt’ -perm 644

查找指定权限的文件
find /path -perm -permission_bits

查找指定文件名的任意类型文件
find /path -name ‘given_name.*’

查找最近更改的文件
find /path -mtime n

其中n为整数:
0表示最近24小时内
1表示最近48小时内
2表示最近72小时内

查找最近访问的文件
find /path -atime n

其中n为整数:
0表示最近24小时内
1表示最近48小时内
2表示最近72小时内

根据所有者查找文件
find /path -user root

查找并且删除文件
find /path -name mytestfile | xargs rm

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>