![]() This command should work on most of the Linux distributions. jpg files older than 7 days.ĭelete files older then find /path/to/files/ -type f -name '*.jpg' -mtime +15 -exec rm \ This is the simple find file command that will list all the. Fourth part -mtime gets how many days the files older then will be listed.Once confirmed, you are good to go to delete those files with the following command. Verify the file list and make sure no useful file is listed in the above command. Third part -name is limiting *,jpg files First of all, list all files older than 30 days under /opt/backup directory.Here using the -mmin and -delete extensions of GNU find, as found on Ubuntu and other GNU-based systems. Second part -type is the file type f stands for files To delete the files whose name starts with master-stdout.log and that have not been modified in the last hour, recursively under /root/logs/: LCALLC find /root/logs/ -name 'master-stdout.log' -mmin +59 -delete.Don’t use wildcard * if you have a lot of files because you will get Argument list too long error. First part is the path where your files are located.With this, you will be able with the Linux find command to find your JPG files older than 30 days and then execute rm or mv or whatever command you want on them.įind files older then find /path/to/files/ -type f -name '*.jpg' -mtime +7 Explanation I needed this for a project where I collected some images and needed to archive and delete them after a while. This is a very simple tutorial on how to find, move and delete files older than X days. While we recommend you use one of the PowerShell methods, without getting into any of the gritty details you can also do it from command prompt. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |