博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

剑心通明的资料库

文章均为转载,本人不负因参考它所导致的一切后果,请谨慎参考!如您的文章不愿被转载,请点击此处联系本人!
  jxtm.cublog.cn

关于作者
姓名:剑心通明
职业:高级工程师(专修灵魂^_^)
年龄:20出头30不到
位置:网络上一节点
个性介绍:努力学习每一天!
倾心打造:http://www.bsdlover.cn
http://bbs.bsdlover.cn
BSD爱好者的乐园!
|| << >> ||
我的分类


如何查找并删除一个小时前创建的文件
Q.How do I find out file last modification time using a shell script or command? How do I delete or take any other custom action for all files more than one hour old in /home/ftp/incoming/raw/ directory?


A.There are many ways (commands) to find out file modification time under UNIX / Linux operating system. You can try any one of the following command:
find command (with -cmin switch)$ find /home/ftp/incoming/raw/ -maxdepth 1 -cmin +60 -name FileName
The -cmin option will print FileName's status was last changed n minutes ago. This command will print all file names more than one hour old.
stat command (with -c switch)To find time of last change as seconds since Epoch, enter:
$ stat -c %Z /path/to/file
date command (with -r switch)To display the last modification time of FILE, enter:
$ date -r /path/to/file
I recommend using find command as it has -exec option to take action on all matching file such as move or delete files:
$ find /home/ftp/incoming/raw/ -maxdepth 1 -cmin +60 -name "*" -exec /bin/rm -f {} \;

 原文地址 http://www.bsdlover.cn/html/46/n-846.html
发表于: 2008-05-03,修改于: 2008-05-03 11:07,已浏览449次,有评论0条 推荐 投诉


网友评论
 发表评论