[Linux] Command to Delete Old Files by Specifying Date and Time
I’ll introduce a Linux command to delete old files by specifying date and time.
The background is the same as [Linux] Command to Check Directories with High Disk Usage.
After identifying directories consuming large amounts of space for disk full response, I researched Linux commands to bulk delete files.
find ./ -mtime +30 | xargs rm -f
# -mtime Last modification time of file data (days)
find command date/time specification options and overview
The Linux command to add file extension specification option to the above command for bulk deletion is as follows:
find ./ -mtime +30 -name "*.jpg" | xargs rm -f
find ./ -atime +30 | xargs rm -f
# -atime Last access time to file (days)
That’s all from the Gemba.