How can I find files updated in last 5 minutes
Finding files changed in last n minutes, hours, days
The general pattern is -mmin
for minutes, and -mtime
for days.
5 Minutes
cd $HOME/.m2
find repository -type f -mmin -5 | grep '\.jar$'
5 hours
cd $HOME/.m2
find repository -type f -mmin -$((5*60)) | grep '\.jar$'
5 days
cd $HOME/.m2
find repository -type f -mtime -5 | grep '\.jar$'
5 months (roughly)
cd $HOME/.m2
find repository -type f -mtime -$((5*30)) | grep '\.jar$'
Find old large files
Files older than 1 year and over 1Gig in size
find /path/to/search -type f -mtime +365 -size +1G
Unit | Suffix | Meaning |
---|---|---|
Bytes | (none) | Default (e.g., -size 1024 means 1024 bytes) |
Kilobytes | k or K |
1 KB = 1024 bytes |
Megabytes | M |
1 MB = 1024 KB (1,048,576 bytes) |
Gigabytes | G |
1 GB = 1024 MB (1,073,741,824 bytes) |
Terabytes | T |
1 TB = 1024 GB (1,099,511,627,776 bytes) |
Finding files by time
Find files newer or old than another file
Find files older than the file /path2/example.txt
find /path1 -type f ! -newer /path2/example.txt
To find files newer than a file remove the !
and files newer than /path2/example.txt will be found.
Find files modified between two dates
find /home/user -type f -newermt "2024-01-01 00:00:00" ! -newermt "2024-02-01 00:00:00"