Quick question about the command find.

Patrick Miguel patrick.miguel at bpe-gruposantander.com
Fri Jun 4 13:30:33 UTC 2010


Hello Maxime,

This is what I use to delete files older than 15 days :

find $MyPath -name "*" -mtime +15 -print -exec rm -rf {} \;

Kind Regards,
Patrick

-----Original Message-----
From: Maxime Alarie <malarie at processia.com>
Reply-to: "Ubuntu user technical support, not for general discussions"
<ubuntu-users at lists.ubuntu.com>
To: Ubuntu user technical support, not for general discussions
<ubuntu-users at lists.ubuntu.com>
Subject: Quick question about the command find.
Date: Fri, 4 Jun 2010 09:21:10 -0400

Good day,

 

I  want to erase files and directories that are older than 15 days..
the command I use is :   find $MyPath –type d –exec rm {} \;

 

Obviously rm wont erase  a non empty directory..  I tried using  rm –r
 but I got errors..  

 

My question is, How can I recursively delete  directories using find –
exec rm  without having to  use 2 commands:  find  . –type f –mtime +15
-exec rm  THEN  find . –type d –exec rmdir

 

Cheers,

 

 

 

 

 


Patrick Miguel 
Santander Private Banking 
Information Technology

5-7 Rue Ami-Lévrier CP 1256 1211 Genève 1 
Tel.: +4122 909 26 14 Fax: +4122 909 62 35 
Email: patrick.miguel at bpe-gruposantander.com


******************AVISO LEGAL**********************
Este mensaje es privado y confidencial y solamente para la persona
a la que va dirigido. Si usted ha recibido este mensaje por error, 
no debe revelar, copiar, distribuir o usarlo en ningun sentido. Le 
rogamos lo comunique al remitente y borre dicho mensaje y 
cualquier documento adjunto que pudiera contener. No hay renuncia 
a la confidencialidad ni a ningun privilegio por causa de 
transmision erronea o mal funcionamiento.
Cualquier opinion expresada en este mensaje pertenece unicamente 
al autor remitente, y no representa necesariamente la opinion de 
Banco Santander, a no ser que expresamente se diga y el remitente 
este autorizado para hacerlo.
Los correos electronicos no son seguros, no garantizan la 
confidencialidad ni la correcta recepcion de los mismos, dado que 
pueden ser interceptados, manipulados, destruidos, llegar con 
demora, incompletos, o con virus. Banco Santander no se hace 
responsable de las alteraciones que pudieran hacerse al mensaje 
una vez enviado.
Este mensaje solo tiene una finalidad de informacion, y no debe 
interpretarse como una oferta de venta o de compra de valores ni 
de instrumentos financieros relacionados.

**********************DISCLAIMER*****************
This message is private and confidential and it is intended 
exclusively for the addressee. If you receive this message by 
mistake, you should not disseminate, distribute or copy this 
email. Please inform the sender and delete the message and 
attachments from your system. No confidentiality nor any privilege 
regarding the information is waived or lost by any mistransmission 
or malfunction.
Any views or opinions contained in this message are solely those 
of the author, and do not necessarily represent those of Banco 
Santander, unless otherwise specifically stated and the sender is 
authorised to do so.
E-mail transmission cannot be guaranteed to be secure, 
confidential, or error-free, as information could be intercepted, 
corrupted, lost, destroyed, arrive late, incomplete, or contain 
viruses. Banco Santander does not accept responsibility for any 
changes in the contents of this message after it has been sent.
This message is provided for informational purposes and should not 
be construed as a solicitation or offer to buy or sell any 
securities or related financial instruments.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20100604/3135cc15/attachment.html>


More information about the ubuntu-users mailing list