Zip is a compression and file packaging utility for Unix, VMS, MSDOS, OS/2, Windows 9x/NT/XP, Minix, Atari, Macintosh, Amiga, and Acorn RISC OS. Some oldĬommand lines that depend on command line inconsistencies may no longer work. Note: Command line processing in zip has been changed to support long options and handle all options and arguments more consistently. Find command output will be sent to rm command as input.Zip Here we can execute the rm command using -exec command line option. Searching all the directories under /var/log modified before 90 days using the command below. In that case, we will use the Linux rm command with find to accomplish the deletion. The -delete option may fail if the directory is not empty. log extension and with the last modification date older than 30 days. The above command will delete only files with a. Once the list is verified, delete those files by running the following command: find /var/log -name "*.log" -type f -mtime +30 -delete find /var/log -name "*.log" -type f -mtime +30
For example, you can only delete files with the “.log” extension and modified before 30 days.įor the safe side, first, do a dry run and list files matching the criteria. You can also specify more filters to locate commands rather than deleting all files. find /opt/backup -type f -mtime +30 -delete 2.
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. Also, if required you can delete them with a single command.įirst of all, list all files older than 30 days under /opt/backup directory. Using the find command, you can search for and delete all files that have been modified more than X days. Here 30 days older means the last modification date is before 30 days.
This article describes you to how to find and delete files older than 30 days.