因此,我正在研究一個bash腳本來清除臨時文件並遇到莫名其妙的行爲。find - mtime vs mmin - 奇怪的結果
# Find using mmin flag
find /usr/local/store/file/temp/3_day/ -mmin +$((60*24*3)) -type f > /tmp/old_files_by_mmin.txt
# Find using mtime flag
find /usr/local/store/file/temp/3_day/ -mtime +3 -type f > /tmp/old_files_by_mtime.txt
diff -u /tmp/old_files_by_mmin.txt /tmp/old_files_by_mtime.txt
前幾行:
--- /tmp/old_files_by_mmin.txt 2016-08-03 16:56:42.535458820 +0000
+++ /tmp/old_files_by_mtime.txt 2016-08-03 16:56:58.310681524 +0000
@@ -117,59 +117,6 @@
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/15/36/1296924350
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/47/52/1950191632
/usr/local/store/file/temp/3_day/image/resize/2016/07/29/11/30/01/711250694
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/44313759
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/1589177813
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/04/15/1189074525
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/10/56/44/91382315
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/09/43/45/1622776054
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/44/57/1465920226
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/23/17/1467026748
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/15/58/1990201487
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/13/19/1990298215
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/01/35/59/518813467
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/10/53/1962045410
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/31/27/290517373
-/usr/local/store/file/temp/3_day/image/resize/2016/07/31/12/05/08/547481306
爲什麼-mmin標誌拿起文件的修改時間標誌是不是?如果兩者都應該找到比現在+ 3天更早的文件?
這可能與四捨五入的日子有關。順便說一句,爲什麼'bash'?就我所知,「find」不是內置的。 – mustaccio
@mustaccio:我懷疑你是對的。不知道你的意思是不是「內置」。這是一個linux系統,所以bash/find總是可用的。 –
@MikePurcell,「內建」意味着「外殼的一部分」,而不是外部工具。如果它不是shell的一部分,那麼你需要指定你的確切操作系統,以及你的操作系統提供哪個版本的工具。 –