Raistlin 发表于 2005-11-3 14:56:02

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

文件的命名是有规范的,前缀_当前日期.log

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

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

P.S.使用的是k shell

MichaelBibby 发表于 2005-11-3 15:49:46

将date命令的输出进行格式化,可能会更有利于脚本的编写
比如:

# date +%Y-%m-%d

pakix 发表于 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
页: [1]
查看完整版本: 请问大家怎么判断一个文件比另一个文件要老多少天?