使用Linux find命令来帮你找到那些很久之前访问过的历史文件

-bash-4.2$ pwd
/data/mongo


计算目录中的文件数
-bash-4.2$ find . -type f | wc -l
227

查找最老的和最新的文件.
最老的文件:
-bash-4.2$ find -type f -printf '%T+ %p\n' | sort | head -n 1
2015-12-19+01:22:31.0000000000 ./.mozilla/firefox/y0w75f7h.default/gmp-gmpopenh264/1.5.3/gmpopenh264.info

最新的文件:
-bash-4.2$ find -type f -printf '%T+ %p\n' | sort | tail -n 1
2016-08-01+14:48:24.7670276210 ./.cache/abrt/lastnotification
(备注:printf 命令输出 %T(文件日期和时间)和 %P(带路径的文件名)参数。)


寻找最大的文件使用 %s(大小)参数,包括文件名(%f):
-bash-4.2$ find -type f -printf '%s %f \n' | sort -n | uniq | tail -1
71932461 mongodb-linux-x86_64-rhel70-v3.2-latest.gz 

统计文件的所有者,使用%u(所有者):
-bash-4.2$ find -type f -printf '%u \n' | grep -v "\./\." | sort | uniq -c
    227 mongo 

找出很久以前访问过的某个文件:
-bash-4.2$ find -type f -printf '%a+ %p\n' | sort | head -n 1
Fri Jul  1 17:05:37.0064013744 2016+ ./.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/.fedora-langpack-install

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15498/viewspace-2122798/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/15498/viewspace-2122798/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值