-2

filename.${date}例如,我有一个名为 的文件列表,foo.20121102我想使用 bash 工具集打印到今天为止具有时间戳的最后修改文件。

4

2 回答 2

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
于 2012-11-10T20:38:42.710 回答
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
}

更多信息在这里

于 2012-11-08T19:14:38.770 回答