2023年7月26日发(作者:)
linux判断⽂件名结尾,find命令⽂件名后缀find命令1、查看当前⽬录下以.txt结尾的⽂件[root@test ~]# find . -name "*.txt"./.subversion/./././不是以.txt结尾的⽂件查找:[root@test ~]# find . ! -name "*.txt"| more../.cshrc./.subversion./.subversion/servers./.subversion/config2、根据⽂件类型查找f 普通⽂件 l 符号连接 d ⽬录 c 字符设备 b 块设备 s 套接字 p Fifo[root@test ~]# find /tmp/ -type d -name mysql/tmp/mysql/tmp/mysql/mysql3、根据⽂件时间戳进⾏搜索Linux⽂件系统每个⽂件都有三种时间戳:访问时间(-atime/天,-amin/分钟):⽤户最近⼀次访问时间。修改时间(-mtime/天,-mmin/分钟):⽂件最后⼀次修改时间。变化时间(-ctime/天,-cmin/分钟):⽂件数据(例如权限等)最后⼀次修改时间。[root@test ~]# stat e: `'Size: 37 Blocks: 8 IO Block: 4096 regular fileDevice: fd00h/64768dInode: 21749 Links: 2Access: (0626/-rw--w-rw-) Uid: ( 0/ root) Gid: ( 0/ root)Access: 2017-10-23 12:12:07.619932872 +0800#当⽂件被访问时变化Modify: 2017-10-23 14:36:12.180013439 +0800#当⽂件被修改时变化Change: 2017-10-23 14:36:12.192013624 +0800#当⽂件被修改时变化+2:2天以外的;-2:2天以内的;xargs:额外扩展[root@test ~]# find . -ctime +2 -name "*.txt"|xargs ls -lt-rw-r--r-- 1 root root 4276 Oct 17 14:45 ./.subversion/-rw-r--r-- 1 root root 4821 Oct 11 04:12 ./setuptools-36.5.0/-info/-rw-r--r-- 1 root root 2939 Oct 11 04:12 ./setuptools-36.5.0/-info/entry_该⽬录10分钟之前被访问过的[root@test ~]# find . -type f -amin +10You have new mail in /var/spool/mail/root该⽬录10分钟之内被访问过的[root@test ~]# find . -type f -amin -10././4、根据⽂件⼤⼩进⾏匹配(K/M/G)4.1 搜索⼤于10KB的⽂件[root@test ~]# find . -type f -size +10k././.bypy/⼩于10KB的⽂件4.2加-i 参数直接⽤ {}就能代替管道之前的标准输出的内容[root@supervisor mnt]# find . -type f -size 1b |xargs -i mv {} /opt[root@test ~]# find . -type f -size -10k5、借助-exec选项与其他命令结合使⽤将".txt"结尾的⽂件都删除[root@test76 83-server]# find . -name '*.txt' -exec rm {} ;6、⽤到-o选项(两个条件满⾜⼀个即可);找出当前⽬录下以.txt,.php结尾的⽂件;[root@test ~]# find . -name '*.php' -o -name '*.txt'./.subversion/./././⽤到-a选项;两个条件同时满⾜[root@test ~]# find . -size +10k -a -size -100k|xargs du -sh52K./.cache/pip/http/2/e/a/f/9/2eaf9e7adb17e72f1ab2b6510f37425dc6772b16K./.cache/pip/http/9/e/6/1/9/9e61964f51d8a05a20ecf21eef694877f28cb52K./.cache/pip/http/c/e/8/8/0/ce880eded052487dc850e45bc88K./.cache/pip/http/d/f/6/b/4/df6b402f6800301aea4d1b04d0c68K./.cache/pip/http/e/8/a/4/5/e8a45d85bbef48356K./.cache/pip/http/f/c/9/f/0/fc9f0666469c64f19c20K./.pip/32K./.bash_history⽂件名后缀file ⽂件名[root@~]# file : POSIX shell script text php解释语⾔.so 库⽂件.bz2 bzip2的压缩⽂件.gz gzip的压缩⽂件.tar tar打包⽂件.sh shell脚本.log ⽇志⽂件
发布者:admin,转转请注明出处:http://www.yc00.com/news/1690361834a337890.html
评论列表(0条)