前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux下35常用的find例子

Linux下35常用的find例子

作者头像
shaonbean
发布2019-05-26 09:36:06
9140
发布2019-05-26 09:36:06
举报
文章被收录于专栏:运维前线运维前线

版权声明:本文为木偶人shaon原创文章,转载请注明原文地址,非常感谢。 https://cloud.tencent.com/developer/article/1434693

#find 实例

root@localhost default# find /tmp/default -size +300k -name *.jpg -exec mv {} /tmp/picture \;

root@localhost default# find /tmp/default -size +300k -name *.png -exec mv {} /tmp/picture \;

root@localhost default# find /tmp/default -size +300k -name *.jpg -o -size +300k -name *.png | wc -l

查找制定文件下制定图片大小,然后移动到指定目录,打包下载

  1. 在当前目录查找文件使用的名字

在当前目录下,查找所有名称为linuxprobe.txt的文件

find . -name linuxprobe.txt

./linuxprobe.txt

  1. 在home目录下查找文件 查找home目录下所有文件名为linuxprobe.txt的文件find /home -name linuxprobe.txt

/home/linuxprobe.txt

  1. 查找文件忽略文件名的大小写 在特定目录下查找名称为linuxprobe.txt的文件,忽略文件名大小写find /home -iname linuxprobe.txt./linuxprobe.txt

./Linuxprobe.txt

  1. 查找特定的目录 根目录下查找目录名为linuxprobe的目录find / -type d -name linuxprobe

/linuxprobe

  1. 查找指定目录下的php文件 查找当前目录下的名为linuxprobe.php的文件find . -type f -name linuxprobe.php

./linuxprobe.php

  1. 查找指定目录下的所有PHP文件find . -type f -name "*.php"./linuxprobe.php ./login.php ./index.php
  2. 查找权限为777的文件 查找当前目录下所有权限为777的文件find . -type f -perm 0777 -print
  3. 查找权限不是777的文件 查找根目录下所有权限不是777的文件find / -type f ! -perm 777
  4. 查找权限为664的文件find / -perm 2644
  5. 找到SUID文件find / -perm /u=sfind / -perm /g=s
  6. 找到只读文件find / -perm /u=r
  7. 找到可执行文件find / -perm /a=x
  8. 找到权限为777的文件并改为644find / -type f -perm 0777 -print -exec chmod 644 {} \;
  9. 找到权限为777的目录并改为755find / -type d -perm 777 -print -exec chmod 755 {} \;
  10. 找到指定的文件并删除find . -type f -name "linuxprobe.txt" -exec rm -f {} \;
  11. 找到指定类型的文件并删除find . -type f -name "*.txt" -exec rm -f {} \;ORfind . -type f -name "*.mp3" -exec rm -f {} \;
  12. 查找空文件find /tmp -type f -empty
  13. 查找空目录find /tmp -type d -empty
  14. 查找所有的隐藏文件find /tmp -type f -name ".*"
  15. 查找指定用户家目录下的指定文件find / -user root -name linuxprobe.txt
  16. 查找指定用户家目录下的所有文件find /home -user linuxprobe
  17. 查找指定组中的所有文件find /home -group developer
  18. 查找指定用户家目录下的指定文件并忽略大小写find /home -user linuxprobe -iname "*.txt"
  19. 查找最近50天修改过的文件find / -mtime 50
  20. 查找最近50天被访问过的文件find / -atime 50
  21. 查找最近50天到100天之间修改过的文件find / -mtime +50 –mtime -100
  22. 查找过去一小时内修改过的文件find / -cmin -60
  23. 查找过去一小时内修改过的文件find / -mmin -60
  24. 查找过去一小时内被访问过的文件find / -amin -60
  25. 查找大小为50M的文件find / -size 50M
  26. 查找文件大小在50M-100M之间的文件find / -size +50M -size -100M
  27. 查找到文件大小为100M的文件并删除find / -size +100M -exec rm -rf {} \;
  28. 查找文件类型为mp3格式并且大小为100M的文件,然后删除find / -type f -name *.mp3 -size +10M -exec rm {} \;

#常用find操作,通过find出指定目录下的特定类型特定名称的文件,然后进行修改,移动,删除等操作。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016年10月18日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • find . -name linuxprobe.txt
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档