Question : how to  exclude .oracle directory is getting deleted through find  ?

Currently we are using following line to remove all files and directories which is older 7 days.
find /tmp -mtime +7 -exec rm -f {} \;

 we need   following directory not to be deleted .( which located in tmp)
drwxrwxrwx   2 oracle9    dba             96 Mar  9 10:33 .oracle

what parameter i need to include in above find command ? help please


Answer : how to  exclude .oracle directory is getting deleted through find  ?

Hello rammaghentharji,

angelIII's solution would be perfect, but I think you only have AIX's 'find', which does not recognize things like "-path"

So I'd suggest you tried this -

find /tmp -mtime +7 -print | grep -v "/tmp/.oracle" | xargs -i{} rm -f {}

Looks rather inelegant, but with AIX-find I can't imagine a better way to accomplish what you want.

I recommend you checked the results of the above command first by issuing

find /tmp -mtime +7 -print | grep -v "/tmp/.oracle" | xargs -i{} echo {}

Alternatively, you could of course install GNU findutils (from the AIX toolbox) and use angelIII's version above.

Cheers

wmp



Random Solutions  
 
programming4us programming4us