यहके उपयोगकर्ता नहीं अनुकूल पहलू है।- आपको समझना होगा कि मिलान वास्तव में आपके खोज मानदंडों को सही तरीके से परिभाषित करने के लिए कैसे काम करता है। निम्नलिखित स्पष्टीकरण जीएनयू खोज (findutils) 4.4.2 पर आधारित है।
find
परीक्षण -atime
, -ctime
, 24 घंटे की अवधि पर -mtime
काम करते हैं, इसलिए के रूप में
floor (current_timestamp - file_modification_timestamp/86400)
को देखते हुए तीन फ़ाइलें 1 घंटे पहले, 25 घंटे पहले संशोधित "फ़ाइल उम्र" को परिभाषित करते हैं और 49 घंटे पहले
$ touch -t $(date -d "1 hour ago" +"%m%d%H%M") a.txt
$ touch -t $(date -d "25 hours ago" +"%m%d%H%M") b.txt
$ touch -t $(date -d "49 hours ago" +"%m%d%H%M") c.txt
फ़ाइल उम्र (जैसा कि ऊपर परिभाषित)
$ echo "($(date +"%s") - $(stat -c %Y a.txt))/86400" | bc
0
$ echo "($(date +"%s") - $(stat -c %Y b.txt))/86400" | bc
1
$ echo "($(date +"%s") - $(stat -c %Y c.txt))/86400" | bc
2
01 हैं
ऊपर देखते हुए यहां क्या लगता है
$ find -type f -mtime 0 # find files with file age == 0, i.e. files modified less than 24 hours ago
./a.txt
$ find -type f -mtime -1 # find files with file age < 1, i.e. files modified less than 24 hours ago
./a.txt
$ find -mtime 1 # find files with file age == 1, i.e. files modified more than (or equal to) 24 hours ago, but less than 48 hours ago
./b.txt
$ find -mtime +1 # find files with file age > 1, i.e. files modified more than 48 hours ago
./c.txt
यह दिखाता है कि -mtime 0
और -mtime -1
बराबर परिणाम दे करता है।
-mmin
बेहतर ग्रैन्युलरिटी के साथ एक ही परीक्षण देता है - तर्क 24 घंटे की अवधि के बजाय मिनट है।
n:
मैं के रूप में अनुसरण कर रहे हैं find
$ touch tmp.txt
$ find * -mtime 0
tmp.txt
$ find * -mtime -1
tmp.txt
क्या आप मुझे समझने में मदद कर सकते हैं कि '-mtime 0' कभी भी उपयोगी कैसे होगा ?? –
अच्छा सवाल। आप उस फ़ाइल को ढूंढ सकते हैं जो घंटे के भीतर बदल दिया गया था। कम से कम मुझे लगता है कि यह क्या करेगा। मैंने वास्तव में यह जांच नहीं की है। – veiset