命令类似
文件管理
命令名称
find
命令描述
查找文件或者目录,根据不同参数的匹配来找到 想要的文件。
命令语法
find [文件路径] [参数或者条件]
参数
-o #或者
-size #大小
-name #条件 如文件名称 或者 相对名称 -name "."
-type #类型 如 f:文件 d:目录 l:库文件
-atime #最近的访问时间
-mtime #最近更改的时间 PS:mtime变化ctime也会跟着变化
-ctime #最近改动时间 Ps:ctime变化 mtime不会跟着变化
##############上面那个是以天表示 下面三个是以分钟表示#######
-amin
-mmin
-cmin
-exec #find查找出来结果 -exec ls {} \; 可以显示出来
案例一:查看一天之内有哪些日志文件被更改内容了
[root@localhost /]# find / -type f -mtime -1 -name "*.log"
/var/log/audit/audit.log
/var/log/tuned/tuned.log
/var/log/boot.log
^C
案例二:把/tmp/下的所有txt文件都增加.bak
[root@localhost /]# find /tmp/ -type f -name "*.txt" -exec mv {} {}.bak \;
[root@localhost /]# find /tmp/ -type f -name "*.txt*" -exec ls {} \;
/tmp/1.txt.bak
/tmp/3.txt.bak
案例三:查找/目录下大于10M的文件
[root@localhost /]# find / -type f -size +10M
/boot/initramfs-0-rescue-05cadc188ccb4cdb80f9fdcf770cfeaf.img
/proc/kcore
find: ‘/proc/3001/task/3001/fdinfo/6’: 没有那个文件或目录
find: ‘/proc/3001/fdinfo/6’: 没有那个文件或目录
/sys/devices/pci0000:00/0000:00:0f.0/resource1_wc
/sys/
注:find命令还是比较强大的 它可以根据你提供的不同参数 如“连接数” 等参数来找出你想要的文件。
本文转自 闪电王 51CTO博客,原文链接:http://blog.51cto.com/sdwaqw/2053713