-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 に答える