[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Effacer les fichiers qui datent de x jours...



Bonjour JM et le monde,

Et pourquoi pas plus simplement :

find ./ -type f -mtime +7 -exec rm {} \;

???

pierre estrem



Le 11/04/2021 à 19:16, Jean-Marc MONGRELET (via linux-31 Mailing List) a écrit :
Le 11/04/2021 17:36, Bernard Schoenacker a écrit :

Sorry, why do not consult the web and the rtfm ?


the answer are disponible on this website :

https://www.2daygeek.com/bash-script-to-delete-files-folders-older-than-x-days-in-linux/

https://stackoverflow.com/questions/13489398/delete-files-older-than-10-days-using-shell-script-in-unix#13489511

Okay... Le secret c'est "-mtime +7" dans la commande find:
find ./ -type f -mtime +7

Donc pour effacer, en tenant compte des fichiers qui ont des espaces dans le nom... ça donne ça:
find ./ -type f -mtime +7 -print0 | xargs -0 -l rm

JM


--