Find files that were modified two days ago:
Find. -type f-mtime-2
Find files that have been modified within 3 days:
Find-ctime-3
Find command uses more than 6 days, empty file Independent query command:
Find/data/backup-ctime +6-exec rm-f {}; Delete files in the/data/backup directory that have been modified for more than 6 days.
Find/data/backup-type d-empty-exec rmdir {}; >/dev/null 2>&1 deletes the empty folder under the/data/backup directory, outputting both the correct and error messages to the null.
Find command for more than 6 days and empty files:
Find./-type d-empty-ctime +6
To find a file by modification time, use the option-mtime:
Find/home/admin-mtime-1 #查找/home/admin Directory to modify the file within 1 days
Find/home/admin-name *.txt-mtime-1 #查找/home/admin directory file with a. txt end of the modified time within 1 days
Find files by file modification time
---(+n)----------|----------(n)----------|----------(-N)---
(n+1) before *24h | (n+1) *24h~n*24h between |n*24h
-ctime-n find files that have been modified from the current n*24h
-ctime n Find files that have been modified (n+1) *24h before now n*24h
-ctime +n Find files that have been modified before (n+1) *24h now
[A|c|m]min [Last visit | final Status Modification | Final content Modification]min
[A|c|m]time [Last visit | final Status Modification | Final content Modification]time
Three times of Linux files (find for example):
Atime last access time, such as LS, more, but chmod, chown, LS, stat, etc. will not modify some time, use Ls-utl can be viewed in this chronological order;
CTime Last state modification time, such as chmod, Chown and other state time changes but the modification time will not change, using stat file can be viewed;
Mtime Last content modification time, such as VI after saving, change time changes, Atime and CTime also change accordingly.
Attention:
The creation time of a file is not recorded in Linux unless the file has not changed since it was created, and its creation time is the last time it was modified.
#ls-lt/home/admin # View in modified chronological order
#ls-lut/home/admin # View by Access time order
(If you want to reverse-order view, you need to add an option-R)