Linux命令Find实例
转自: http://www.tecmint.com/35-practical-examples-of-linux-find-command/
35 Practical Examples of Linux Find Command
- Part I: Basic Find Commands for Finding Files with Names
 - Part II: Find Files Based on their Permissions
 - Part III: Search Files Based On Owners and Groups
 - Part IV: Find Files and Directories Based on Date and Time
 - Part V: Find Files and Directories Based on Size
 
1. Find Files Using Name in Current Directory
Find all the files whose name is tecmint.txt in a current working directory.
# find . -name tecmint.txt ./tecmint.txt
2. Find Files Under Home Directory
Find all the files under /home directory with name tecmint.txt.
# find /home -name tecmint.txt /home/tecmint.txt
3. Find Files Using Name and Ignoring Case
Find all the files whose name is tecmint.txt and contains both capital and small letters in/home directory.
# find /home -iname tecmint.txt ./tecmint.txt
./Tecmint.txt
4. Find Directories Using Name
Find all directories whose name is Tecmint in / directory.
# find / -type d -name Tecmint /Tecmint
5. Find PHP Files Using Name
Find all php files whose name is tecmint.php in a current working directory.
# find . -type f -name tecmint.php ./tecmint.php
6. Find all PHP Files in Directory
Find all php files in a directory.
# find . -type f -name "*.php" ./tecmint.php
./login.php
./index.php
7. Find Files With 777 Permissions
Find all the files whose permissions are 777.
# find . -type f -perm 0777 -print
8. Find Files Without 777 Permissions
Find all the files without permission 777.
# find / -type f ! -perm 777
9. Find SGID Files with 644 Permissions
Find all the SGID bit files whose permissions set to 644.
# find / -perm 2644
10. Find Sticky Bit Files with 551 Permissions
Find all the Sticky Bit set files whose permission are 551.
# find / -perm 1551
11. Find SUID Files
Find all SUID set files.
# find / -perm /u=s
12. Find SGID Files
Find all SGID set files.
# find / -perm /g+s
13. Find Read Only Files
Find all Read Only files.
# find / -perm /u=r
14. Find Executable Files
Find all Executable files.
# find / -perm /a=x
15. Find Files with 777 Permissions and Chmod to 644
Find all 777 permission files and use chmod command to set permissions to 644.
# find / -type f -perm 0777 -print -exec chmod 644 {} \;
16. Find Directories with 777 Permissions and Chmod to 755
Find all 777 permission directories and use chmod command to set permissions to 755.
# find / -type d -perm 777 -print -exec chmod 755 {} \;
17. Find and remove single File
To find a single file called tecmint.txt and remove it.
# find . -type f -name "tecmint.txt" -exec rm -f {} \;
18. Find and remove Multiple File
To find and remove multiple files such as .mp3 or .txt, then use.
# find . -type f -name "*.txt" -exec rm -f {} \;
OR
# find . -type f -name "*.mp3" -exec rm -f {} \;
19. Find all Empty Files
To file all empty files under certain path.
# find /tmp -type f -empty
20. Find all Empty Directories
To file all empty directories under certain path.
# find /tmp -type d -empty
21. File all Hidden Files
To find all hidden files, use below command.
# find /tmp -type f -name ".*"
22. Find Single File Based on User
To find all or single file called tecmint.txt under / root directory of owner root.
# find / -user root -name tecmint.txt
23. Find all Files Based on User
To find all files that belongs to user Tecmint under /home directory.
# find /home -user tecmint
24. Find all Files Based on Group
To find all files that belongs to group Developer under /home directory.
# find /home -group developer
25. Find Particular Files of User
To find all .txt files of user Tecmint under /home directory.
# find /home -user tecmint -iname "*.txt"
26. Find Last 50 Days Modified Files
To find all the files which are modified 50 days back.
# find / -mtime 50
27. Find Last 50 Days Accessed Files
To find all the files which are accessed 50 days back.
# find / -atime 50
28. Find Last 50-100 Days Modified Files
To find all the files which are modified more than 50 days back and less than 100 days.
# find / -mtime +50 –mtime -100
29. Find Changed Files in Last 1 Hour
To find all the files which are changed in last 1 hour.
# find / -cmin -60
30. Find Modified Files in Last 1 Hour
To find all the files which are modified in last 1 hour.
# find / -mmin -60
31. Find Accessed Files in Last 1 Hour
To find all the files which are accessed in last 1 hour.
# find / -amin -60
32. Find 50MB Files
To find all 50MB files, use.
# find / -size 50M
33. Find Size between 50MB – 100MB
To find all the files which are greater than 50MB and less than 100MB.
# find / -size +50M -size -100M
34. Find and Delete 100MB Files
To find all 100MB files and delete them using one single command.
# find / -size +100M -exec rm -rf {} \;
35. Find Specific Files and Delete
Find all .mp3 files with more than 10MB and delete them using one single command.
# find / -type f -name *.mp3 -size +10M -exec rm {} \;
That’s it, We are ending this post here, In our next article we will discuss more about other Linux commands in depth with practical examples. Let us know your opinions on this article using our comment section.
Linux命令Find实例的更多相关文章
- Linux chmod命令修改文件与文件夹权限的命令附实例
		
Linux chmod命令修改文件与文件夹权限的命令附实例 作者:佚名 字体:[增加 减小] 来源:互联网 时间:05-01 20:46:07我要评论 在linux中要修改一个文件夹或文件的权限我们需 ...
 - linux scp命令参数及用法详解--linux远程复制拷贝命令使用实例【转】
		
转自:http://blog.csdn.net/jiangkai_nju/article/details/7338177 一般情况,本地网络跟远程网络进行数据交抱,或者数据迁移,常用的有三种方法,一是 ...
 - linux常用命令加实例大全
		
目 录引言 1一.安装和登录 2(一) login 2(二) shutdown 2(三) halt 3(四) reboot 3(五) ...
 - Linux命令行抓包及包解析工具tshark(wireshark)使用实例解析
		
在Linux下,当我们需要抓取网络数据包分析时,通常是使用tcpdump抓取网络raw数据包存到一个文件,然后下载到本地使用wireshark界面网络分析工具进行网络包分析. 最近才发现,原来wire ...
 - 实例解说Linux命令行uniq
		
Linux命令uniq的作用是过滤重复部分显示文件内容,这个命令读取输入文件,并比较相邻的行.在正常情况下,第二个及以后更多个重复行将被删去,行比较是根据所用字符集的排序序列进行的.该命令加工后的结果 ...
 - linux常用命令与实例小全
		
转至:https://www.cnblogs.com/xieguohui/p/8296864.html linux常用命令与实例小全 阅读目录(Content) 引言 一.安装和登录 (一) ...
 - Linux命令随笔
		
Linux命令总结 man ==命令帮助; help ==命令的帮助(bash的内置命令); ls ==list,查看目录列表; -ld:查看目录权限; -l:(long)长格式显示属性; -F:给不 ...
 - 每天一个 Linux 命令(21):find命令之xargs
		
在使用 find命令的-exec选项处理匹配到的文件时, find命令将所有匹配到的文件一起传递给exec执行.但有些系统对能够传递给exec的命令长度有限制,这样在find命令运行几分钟之后,就会出 ...
 - 第2章 新手必须掌握的Linux命令
		
第2章 新手必须掌握的Linux命令 章节简述: 本章节讲述系统内核.Bash解释器的关系与作用,教给读者如何正确的执行Linux命令以及常见排错方法. 经验丰富的运维人员可以恰当的组合命令与参数 ...
 
随机推荐
- gulp-px2rem-plugin 插件的一个小bug
			
最近在使用这个插件的过程中发现一个bug: 不支持 含有小数的形式. 查看源码后,修改了下其中的正则,使其支持小数形式(66.66px..6px ). 作者的源码最近一次更新都在两年前,所以就简单的记 ...
 - NodeJs>------->>第二章:Node.js中交互式运行环境--------REL
			
第二章:Node.js中交互式运行环境--------REL 一:REPL运行环境概述 C:\Users\junliu>node > foo = 'bar' ; 'bar' > 二: ...
 - JavaScript错误:Maximum call stack size exceeded错误
			
错误的表面意思是,因为递归次数太多而内存溢出, 当然引起溢出的原因很多 找了下问题来源,发现引用了两个版本的jquery,在layout.cshtml母模块页中和视图中都引用了jq.导致循环调用,从而 ...
 - CentOS 用挂了dev/sda1:UNEXPECTED INCONSISTENCY;RUN fsck MANUALLY .
			
dev/sda1:UNEXPECTED INCONSISTENCY;RUN fsck MANUALLY .(i.e. ,without -a or -p options)fsck died with ...
 - Mysql innodb_fast_shutdown
			
innodb_fast_shutdown有3个值: 默认是1 可选0 1 2 支持全动态局设置 使用场景:在做数据库关闭升级的时候 set global innodb_fast_shutdown=0 ...
 - What Are You Talking About HDU1075
			
一开始我也想用map 但是处理不好其他字符.. 看了题解 多多学习! 很巧妙 就是粗暴的一个字符一个字符的来 分为小写字母和非小写字母两个部分 一但单词结束的时候就开始判断. #includ ...
 - 【Java】 剑指offer(38) 字符串的排列
			
本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集 题目 输入一个字符串,打印出该字符串中字符的所有排列.例如输入字符串ab ...
 - C语言 —— 贪吃蛇
			
参考视频:https://www.bilibili.com/video/av29580072/?p=1 GreedySnake.h #ifndef GREEDYSNAKE_H_INCLUDED #de ...
 - [OpenCV-Python] OpenCV 中的图像处理 部分 IV (三)
			
部分 IVOpenCV 中的图像处理 OpenCV-Python 中文教程(搬运)目录 19 Canny 边缘检测 目标 • 了解 Canny 边缘检测的概念 • 学习函数 cv2.Canny() 1 ...
 - git add Untracked files
			
git add * 将目录里的所有文件提交到暂存区后 git status 查看状态 所有文件都是绿色的表示本地的文件和暂存区的文件是一样的 然后在本地修改一个文件 然后新建一个文件 在使用git ...