当前位置:网站首页>find查找多类型结尾文件
find查找多类型结尾文件
2022-08-02 10:36:00 【-小-白-】
工作中find的使用程度还算是蛮频繁的,下面列举一下find命令查找文件的方式以及一些常用的参数选项含义。
1、各选项含义
按名称和文件属性为条件
-name '字串' 查找文件名匹配所给字串的所有文件,字串内可用通配符 *、?、[ ]
-lname '字串' 查找文件名匹配所给字串的所有符号链接文件,字串内可用通配符 *、?、[ ]
-gid n 查找属于ID号为 n 的用户组的所有文件
-uid n 查找属于ID号为 n 的用户的所有文件
-group '字串' 查找属于用户组名为所给字串的所有的文件
-user '字串' 查找属于用户名为所给字串的所有的文件
-empty 查找大小为 0的目录或文件
-path '字串' 查找路径名匹配所给字串的所有文件,字串内可用通配符*、?、[ ]
-perm 权限 查找具有指定权限的文件和目录,权限的表示可以如711,644
-size n[bckw] 查找指定文件大小的文件,n 后面的字符表示单位,缺省为 b,代表512字节的块
-type x 查找类型为 x 的文件,x 为下列字符之一:
b 块设备文件
c 字符设备文件
d 目录文件
p 命名管道
f 普通文件
l 符号链接文件
s socket文件
-xtype x 与 -type 基本相同,但只查找符号链接文件
按时间为条件
-amin n 查找n分钟前被访问过的所有文件
-atime n 查找n天前被访问过的所有文件
-cmin n 查找n分钟前文件状态被修改过的所有文件
-ctime n 查找n天前文件状态被修改过的所有文件
-mmin n 查找n分钟前文件内容被修改过的所有文件
-mtime n 查找n天以前文件内容被修改过的所有文件
以上选项中的‘n’可以有三种 假设‘n’为10
+10 表示10以后
-10 表示10以前
10 表示正好10
可执行的操作
-exec 命令名称 {} 对符合条件的文件执行所给的Linux 命令,而不询问用户是否需要执行该命令{}表示命令的参数即为所找到的文件;命令的末尾必须以“ \;”结束
-ok 命令名称 {} 对符合条件的文件执行所给的Linux 命令,与exec不同的是,它会询问用户是否需要执行该命令
-ls 详细列出所找到的所有文件
-fprintf 文件名 将找到的文件名写入指定文件
-print 在标准输出设备上显示查找出的文件名
-printf 格式 格式的写法请参考有关C语言的书
2、查找多类型文件
##使用-o参数过滤
find / -type f -name "*.txt" -o -name "*.doc"
##查找所有文件过滤多类型
find / -type f |egrep "\.(dmp|bak|txt|csv|xls|doc|dat)$"
边栏推荐
- 为什么要使用BGP?
- The 38-year-old daughter is not in love and has no stable job, the old mother is crying
- 一体化在线政务服务平台,小程序容器技术加速建设步伐
- armv7与armv8的区别(v8和w12的区别)
- Com多进程通信实现
- MySql模糊查询大全
- 38岁女儿不恋爱没有稳定工作老母亲愁哭
- MySQL百万数据优化总结 一
- R language time series data arithmetic operation: use the log function to log the time series data, and use the diff function to calculate the successive difference of the logarithmic time series data
- 鸿星尔克再捐一个亿
猜你喜欢
神通数据库,批量插入数据的时候失败
软件工程国考总结——选择题
详细总结SoC、DSP、MCU、GPU和FPGA等基础概念
MSYS2 QtCreator Clangd code analysis can not find mm_malloc.h problem remedy
从测试入门到测试架构师,这10年,他是这样让自己成才的
Why use BGP?
365天挑战LeetCode1000题——Day 047 设计循环队列 循环队列
阿里CTO程立:阿里巴巴开源的历程、理念和实践
npm ERR! 400 Bad Request - PUT xxx - Cannot publish over previously published version “1.0.0“.
C#/VB.NET to add more lines more columns image watermark into the Word document
随机推荐
Failed to configure mysql, what's going on?
Jay Chou's new song is released, crawl the "Mojito" MV barrage, and see what the fans have to say!
C#/VB.NET 添加多行多列图片水印到Word文档
Shell script realizes multi-select DNS simultaneous batch resolution of domain name IP addresses (new update)
链表的实现
logo 图标(php图片加文字水印)
记一次mysql查询慢的优化历程
Hello, my new name is "Bronze Lock/Tongsuo"
从零开始Blazor Server(5)--权限验证
R language ggplot2 visualization: use the ggbarplot function of the ggpubr package to visualize the stacked bar plot, the lab.pos parameter specifies the position of the numerical label of the bar cha
通过方法引用获取方法名
365天挑战LeetCode1000题——Day 047 设计循环队列 循环队列
21年毕业转行软件测试,从0收入到月薪过万,我真的很幸运...
Alibaba CTO Cheng Li: Alibaba Open Source History, Concept and Practice
DVWA Clearance Log 2 - Command Injection
Verilog's random number system task----$random
LayaBox---TypeScript---Symbols
LayaBox---TypeScript---Mixins
全方位剖析Numpy中的np.diag源代码
阿里CTO程立:阿里巴巴开源的历程、理念和实践