手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux基础教程:Linux find命令用法小结

[日期:2011-12-17] 来源:Linux社区  作者:Linux [字体:大 中 小]

6、按时间查找

查找2天内被更改过的文件

[root@localhost .code]# find . -mtime -2 -type f -print

查找2天前被更改过的文件

[root@localhost .code]# find . -mtime +2 -type f -print

查找一天内被访问的文件

[root@localhost .code]# find . -atime -1 -type f -print

查找一天前被访问的文件

[root@localhost .code]# find . -atime +1 -type f -print

查找一天内状态被改变的文件

[root@localhost .code]# find . -ctime -1 -type f -print

查找一天前状态被改变的文件

[root@localhost .code]# find . -ctime +1 -type f -print

查找10分钟以前状态被改变的文件

[root@localhost .code]# find . -cmin +10 -type f -print

7、按文件新旧

查找比aa.txt新的文件

[root@localhost .code]# find . -newer "aa.txt"  -type f -print

查找比aa.txt旧的文件

[root@localhost .code]# find . ! -newer "aa.txt"  -type f -print

查找比aa.txt新,比bb.txt旧的文件

[root@localhost .code]# find . -newer 'aa.txt' ! -newer 'bb.txt' -type f -print

8、按大小查找

查找超过1M的文件

[root@localhost .code]# find / -size +1M -type f -print

查找等于6字节的文件

[root@localhost .code]# find . -size 6c -print

查找小于32k的文件

[root@localhost .code]# find . -size -32k -print

9、执行命令

查找del.txt并删除,删除前提示确认

[root@localhost .code]# find . -name 'del.txt' -ok rm {} \;

查找aa.txt 并备份为aa.txt.bak

[root@localhost .code]# find . -name 'aa.txt' -exec cp {} {}.bak \; 

linux
相关资讯       Linux find命令 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款