Introduction
Useful list of example for search and compress files by modification date.
Search by date
Find files updated in the last 24 hours
[root@localhost tmp]# find -type f -mtime 0
Find files updated today
[root@localhost tmp]# find -type f -newermt `date +%F`
Find files updated in the last 48 hours
[root@localhost tmp]# find -type f -mtime -2
Find files modified by yesterday
[root@localhost tmp]# find -type f -newermt `date +%F -d yesterday`
Find files updated in the last 72 hours
[root@localhost tmp]# find -type f -mtime -3
Search for files modified up to 3 days ago
[root@localhost tmp]# find -type f -newermt `date +%F -d -3days`
Find files modified after July 1, 2022
[root@localhost tmp]# find -type f -newermt 2022-07-01
Search by time
Find files updated in the last 3 hours
[root@localhost tmp]# find -type f -mmin -180#OR[root@localhost tmp]# find -type f -newermt `date +%F -d -3hours`
Search by file name
Find TXT files updated today
[root@localhost tmp]# find -type f -newermt `date +%F` -name *.txt
Compress the searched files directly
[root@localhost tmp]# find -mtime -10 | xargs tar cvf archive.tar.gz