How to Find files in a specific range.
Find command is a faster way to retrieve the files. it is better than ls. ls is slower when the number of files increased.
Find the Files OLDER than X days on Linux
Command Syntax
find /path/to/files -mtime +<number of days> -printf '%T+ %p\n' [| sort -r | head -100 ]
Note that there are spaces between rm, {}, and \;
Find Files created in the Last X days
Command Syntax
find /path/to/files -mtime -<number of days> -printf'%T+ %p\n'
To Delete files created in the last x days only change -mtime argument it takes -<number of days> rather +<number of days>
Find Files older than x minutes
Command Syntax
find /path/to/files -mmin +<minutes> -printf'%T+ %p\n'
Delete files created in x minutes
find /path/to/files -mmin -<minutes> -printf'%T+ %p\n'