.gz是什么文件-我在linux中高频使用的find命令回顾

生活百科10个月前发布 aixure
45 0 0

1、通过扩展名查找文件

> find . -name "*.txt"
> find / -name "*.log"

2、按文件名查找

> find / -name error.log
> find / -name nginx.conf

3、按所属组所有者查找文件

> find ~ -group rumenz -print

> find ~ -user rumenz -print

> find /home -nouser -print

4、按权限查找文件

> find . -perm 755  -print  #查找当前目录下755权限的文件 

5、按类型查找文件

> find . -type d -print   #查找当前目录下的所有目录
> find . ! -type d -print #查找当前目录下除了目录的其他所有类型文件

6、按修改日期查找文件

> find . -mtime -3 -print  #查找更改时间在3天之内的文件
> find . -mtime -2 -print  #查找更改时间在2天之前的文件

7、按大小查找文件

> find . -size 100c -print #查找当前目录下文件长度为100字节的文件
> find . -size +10 -print  #查找当前目录下超过10块的文件(1块=512字节)
> find / -size +100M       #查找系统中文件大小超过100M的文件

8、排除某个目录

> find /rumenz -path "/rumenz/src" -prune -o -print     

> find /rumenz -path "/rumenz/src" -prune -o -name "*.txt" -print

9、目录与文件查找顺序

> find /rumenz -depth -print

10、正则查找

查找当前目录及子目录中查找文件名以大写字母开头的文件

> find . -name "[A-Z]*" -print    

查找某个文件夹下面的哪些具体文件包含某一个字段

> find . | xargs grep "YZS"

11、查找并对结果做相关操作

12、匹配多个文件

> find . (  -name "*.txt" -o -name "*.pdf" )

-o 为 or的意思

13、find排除某个目录

find 查找路径 -path排除目录路径

> find . -path './home' -prune -o -name *.log

find后面的第一个英文点号.表示当前根路径,-path ./home表示匹配路径为./home的文件夹,-prune表示把前面命令所匹配到的路径排除,不再进入该路径下面继续查找,-o表示或,-name表示查找log后缀的文件.gz是什么文件.gz是什么文件,-print表示打印查找结果到命令行终端。

.gz是什么文件-我在linux中高频使用的find命令回顾

img

最右边为当前时,+5 代表大于等于 6 天前的档案名, -5 代表小于等于 5 天内的档案名,5 则是代表 5-6 那一天的档案名。

find与时间有关的选项有-atime(访问时间)、-ctime(创建时间)、-mtime(属性修改时间),参数为后面跟的时间n;

> find . -atime n     这里的n表示n天之前的“一天之内”被访问过的文件
> find . -atime +n   列出在n天之前(不包含n天本身)被访问过的文件
> find . -atime -n    列出在n天之内(包含n天本身)被访问过的文件

1:创建文件

> touch -a -d "2021-01-01 15:00" a.txt
> touch -a -d "2021-01-02 15:00" b.txt
> touch -a -d "2021-01-03 15:00" c.txt
> touch -a -d "2021-01-04 15:00" d.txt
> touch -a -d "2021-01-05 15:00" e.txt
> touch -a -d "2021-01-06 15:00" f.txt
> touch -a -d "2021-01-07 15:00" g.txt
> touch -a -d "2021-01-08 15:00" h.txt

2:以下三条命令得到的结果分别为:

限时特惠:本站每日持续更新海量各大内部网赚创业教程,会员可以下载全站资源点击查看详情
站长微信:
.gz是什么文件-我在linux中高频使用的find命令回顾

© 版权声明

相关文章

暂无评论

暂无评论...