linux: remove files older than a certain number of days

want the command to remove files (on linux) that are older than a certain number of days? shazam! here you go:

the below command will:

  • remove files (note the rm in the command)

  • located in the current directory (note the ./ in the command)

  • that are older than 30 days (note the +30 in the command)

find ./ -mtime +30 -exec rm {} \;

here’s another example, the below command will:

  • remove files (note the rm in the command)

  • located in any directory in /home whose name starts with oracle (note the /home/oracle* in the command)

  • that are older than 5 days (note the +5 in the command)

find /home/oracle* -mtime +5 -exec rm {} \;
Previous
Previous

create a java web service client from a wsdl

Next
Next

linux list directory size, list directories and their sizes