find命令、文件名后缀

2.23/2.24/2.25 find命令

find 搜索文件的命令
which ls:从环境变量  echo $PATH 中找的
whereis ls : 可以搜索,搜的不全
安装: locate
[root@wangshuang-01 ~]# yum install -y mlocate
模糊搜索:locate  +关键字

find /etc/  -name  "sshd*"


根据文件的类型搜文件
搜目录
find  /etc/  -type  d  -name  "*.d"
搜文件
find  /etc/  -type  f  -name  "sshd*"


搜软链接
find  /etc/  -type  l  

搜socket文件
find  /dev/  -type  s  

搜字符串文件
find  /dev/  -type  c 

搜块设备
find  /dev/  -type  b  

find  /  -type -name -mtime -ctime -atime 
stat    查看文件的具体信息的,名字、大小、块、设备、权限、最近访问、更改时间等


Access:访问文件的时间,cat文件、more文件
Modify:修改文件 内容
Change:修改文件 权限,修改文件内容(大小、时间、权限、所有者、所属组)
修改文件权限,ctime会变,mtime不会变

更改文件的内容,ctime 一定会变,mtime也会变

访问文件.  cat 1.txt ,atime 一定会变

查找在一天以内创建或修改的文件
[root@wangshuang-01 ~]# find / -type f -mtime -1
查找大于一天内创建或修改的文件
[root@wangshuang-01 ~]# find / -type f -mtime +1
查找一天以内在该路径下创建或修改的文件
[root@wangshuang-01 ~]# find /etc/ -type f -mtime -1
/etc/resolv.conf
/etc/group
/etc/gshadow
/etc/shadow
/etc/tuned/active_profile
[root@wangshuang-01 ~]# find /etc/ -type f -atime -1
[root@wangshuang-01 ~]# find /etc/ -type f -ctime -1
添加查找条件,-type,-ctime,-name 是并且的关系
[root@wangshuang-01 ~]# find /etc/ -type f -ctime -1 -name "*.conf"
/etc/resolv.conf
/etc/updatedb.conf
添加的查找条件,-ctime,-name 是或者的关系
[root@wangshuang-01 ~]# find /etc/ -type f -o -ctime -1 -o -name "*.conf"
根据inode号查找硬连接文件

查找60 分钟内创建的文件
[root@wangshuang-01 ~]# find /root/ -type f -mmin -60
/root/1.txt
查找60分钟内创建的文件,并且显示文件的详细信息
[root@wangshuang-01 ~]# find /root/ -type f -mmin -60 -exec ls -l {} \;
-rw-r--r--. 1 777 root 12 Jun 10 20:38 /root/1.txt
查找文件在200分钟内创建,且修改文件名称,在文件名称后加  .bak

查找文件的大小,大于10k,小于10k

[root@wangshuang-01 ~]# find /root/ -type f -size +10k -exec ls -lh {} \;
[root@wangshuang-01 ~]# find /root/ -type f -size -10k -exec ls -lh {} \;

总结:find 常用命令,find -type ,-mtime , -mmin , -size , -o , -exec , -name

2.26 文件名后缀
在linux 下面可以自定义文件名及后缀,不能代表文件的类型,
修改语言:






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值