Find files of a specific age / date and then remove them

The following command will find all files with the extension *.mp3 that are 7 days old or older, it will then delete them.

find /home/music/ -name "*.mp3" -mtime +7 -exec rm {} \;

Change the -mtime to set how how old the files are that you want the action to apply to.

After -exec, you can put any command you like, such as remove, rename, compress etc.

Print Friendly, PDF & Email

More Like This


Categories


Linux
  • Post a comment