QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 908|回复: 2

请问大家怎么判断一个文件比另一个文件要老多少天?

[复制链接]
发表于 2005-11-3 14:56:02 | 显示全部楼层 |阅读模式
文件的命名是有规范的,前缀_当前日期.log

例如前缀是abc,那么文件名就是abc_20051101.log,第二天就是abc_20051102.log,依次类推

我的目的是要删除所有比今天创建的文件老三天或者三天以上的log文件,应该怎么写代码呢?

P.S.使用的是k shell
发表于 2005-11-3 15:49:46 | 显示全部楼层
将date命令的输出进行格式化,可能会更有利于脚本的编写
比如:
[code:1]
# date +%Y-%m-%d
[/code:1]
回复

使用道具 举报

发表于 2005-11-11 19:14:59 | 显示全部楼层
why don't u use the FS's timestamp?
OS will stamp the time for u automatically

u should google the following terms:
ctime, mtime, atime

and then man the following command:
touch, find
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-7-3 10:29 , Processed in 0.066867 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表