我有一个名为filename.${date}
的文件列表,例如foo.20121102
,我想使用bash工具集打印最新修改过的文件,该文件的时间戳到今天为止。
答案 0 :(得分:1)
使用shell
就像你问的那样:
for i in *; do
if stat -c %y "$i" | grep -q "^$(date +%Y-%m-%d)"; then
echo "$i has been modified or created today"
else
echo "$i has NOT been modified or created today"
fi
done
答案 1 :(得分:0)
# 24 hours * 60 minutes/hour * 60 seconds/minute
$threshhold = 86400;
$currenttime = time();
if( ($currenttime - $mtime) > $threshhold){
# file was modified within 24 hours
}
对于午夜午夜后修改的文件:
if( $mtime > ($currenttime - ($currenttime % 86400)){
# file was modified this calendar day
}
更多信息here