heidsoft / cloud-bigdata-book

write book
56 stars 33 forks source link

find 命令 #36

Open heidsoft opened 6 years ago

heidsoft commented 6 years ago

查找最近7天访问过的文件 find . -type f -atime -7 -print

打印恰好7天前访问过的文件 find . -type f -atime 7 -print

打印访问时间超过7天访问过的文件 find . -type f -atime +7 -print

找出访问时间大于7分钟的文件 find . -type f -amin +7 -print

找出文件小于2k的文件 find . -type f -size -2k

找出文件大于2k的文件 find . -type f -size +2k

查找深度为1 类型为目录 名称匹配mw的目录 find . -maxdepth 1 -type d -name "mw*" -print

查找到相关文件,并删除文件 find . -maxdepth 3 -type f -name "*.log" -delete

指定过滤文件来查找 find . -maxdepth 5 ( -name ".yml" -prune ) -o ( -name ".git" -prune ) -o ( -type f -print )

查找文件并执行命令,对文件进行查看 find . -type f -name "*.sh" -exec cat {} \;