Find 3 months old log files and remove

HI

I HAVE LOG FILES IN THIS FORMAT

XXX.log.20080509215745
XXX.log.20080209205745
XXX.log.20080301785745
XXX.log.20080109155745
XXX.log.20080409115745
XXX.log.20080309105745

I NEED TO FIND THE FILES FROM 3 MONTHS OLD AND REMOVE

PLEASE HELP

THANKS,

find /yourdir -type f -name "filename.*" -mtime +90 -exec rm {} \;

#find . -name *.log* -mtime +90 -exec rm {} \;
but before that get a listing to see what you are about to delete
#find . -name *.log.* -mtime +90 -exec ls -tl {} \;
Search and remove is a potentially dangerous command make sure you are in the directory where you are deleting files find . means present directory

Thanks for the reply

I tried the command

find . -name *.log.* -mtime +90 -exec ls -tl {} \;

getting error Arg list too long

bash-2.03$ find . -name *.log.* -mtime +90 -exec ls -tl {} \;
bash: /usr/bin/find: Arg list too long

Thanks,

your bash could be causing the problem or your dir might be over-growing

Tried with out bash

$ find . -name *.log.* -mtime +90 -exec ls -tl {} \;
ksh: /usr/bin/find: arg list too long

getting the same error

Directory has different type of files
like

*.log
*.log.20080502124557

try this?
$ find . -name *.log -mtime +90 -exec ls {}\;

Tried find . -name *.log -mtime +90 -exec ls {}\;

Getting bad option xxxx.log file

$ find . -name *.log -mtime +90 -exec ls {}\;
find: bad option xxxx.log
find: path-list predicate-list

oh my...! pls find your way around the syntax. u ed not post every single issue.
try this.
find <use_path> -name *.log -mtime +90 -exec ls

this really should work. if not then I am not sure what to tell you.

find . -name "*.log" -mtime +90 -exec ls {} \;

i guess it is possible that there are so many files that the exec has problems. maybe try this:

find . -name "*.log" -mtime +90 -print

and see if that gets it.

btw, i always have to use quotes in my find statements when I use a wildcard. your mileage may vary.

Pls make sure that you are using a space between {} and \;

Since you are dealing with special characters again - basically trying to look for all *.log.* files, you need to either use a \ or surround *.log.* with double quotes.....like this:

find . -name "*.log.*" -mtime +90 -exec ls {} \;

OR

find . -name \*.log.\* -mtime +90 -exec ls {} \;

(Make sure you are in the right directory by using pwd command).

Please get back and let us know if that worked....Cheers!

Tried both no result

$ find . -name \*.log.\* -mtime +90 -exec ls {} \;
$
$ find . -name "*.log.*" -mtime +90 -exec ls {} \;
$

sori cvdev I forgot to include the space as mentioned by hercu. am busy and was rushing with some stuff.. are u in the correct dir? use the wild card either before or aft the word .log and see.. use hercu's syntax.

Thanks every one its working.