How do i delete files older than 15 days in AIX?

Hi i have tried searching and googling, but cant quite get there

I need to delete all files in a directory that are older than 15 days

here is what i have tried

find /path/to/files* -mtime +15 -exec del {} \;

the first section works

find /path/to/files* -mtime +15

but the del command dosent

i know its probably really obvious, but im an AIX noob and not sure how to close it off

cheers for any help!

find /path/to/files* -mtime +15 -exec rm -f {} \;

Consider making sure you only delete regular files:

find /path/to/files* -mtime +15 -type f -exec rm -f \{\} \;

This will leave any directory structures under the initial point intact.

You also have a wild card in the find path, if this is to be a script you may wish to reconsider that as it the fututre it may have unintended side effects.

This is correct and i wonder if wildcards in the path are supported at all. Maybe this is just working because some strange side effect.

"Searching and googling" should have revealed up to now that "del" is not a UNIX command at all. I did try and entered "delete files unix" into google, this was the first link to come up: how to delete files.

bakunin

Just another way of doing the same.

find /path/to/files* -mtime +15 -type f | xargs -I xx rm -f xx

I just wanted to mention you are wanting to get files that have not been modified in more than 15 days and not files that have not been accessed in more than 15 days right? Use the -atime if you want get files that have not been accessed in more than 15 days.

Just to touch on the wildcard as others have, if you are checking all files in your pathtofiles directory then you don't need it at all. If you are just wanting the files that start with "a" for example to be looked at in that directory then add the -name option with a file card there.

find /path/to/files -name "a*" -mtime +15 -type f | xargs -I xx rm -f xx