Find

Find sur Fichier .xml de plus de 90 jours :

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

Find sur fichier sess de plus de 3 jours :

find . -type f -name "sess_*" -mtime +3 -exec rm {} \;

Find pour affchier les dossiers consommateurs d'inodes :

for i in `find . -type d `; do echo `ls -a $i | wc -l` $i; done | sort -n

Boucle Find avec descendence sur 2 niveaux :

for i in $(find /space/www/ -mindepth 2 -user root | grep -v default | grep bower) ; do echo $i ; done

for i in $(find /space/www/ -mindepth 2 -user root | grep -v default | grep bower) ; do chown -h webadmin: $i ; done

Find dans acces.log pour sortir des IP d'un jour précis :

find -name \*access\*log -exec awk /$day':05/,0' {} \; | cut -d ' ' -f 1  | sort | uniq -c | sort | tail

Find couplé à un grep :

find /path/to/log/file -type f -name "access.log*" -mtime -46 -exec zgrep "HTTP\/1\.1\" 404" {} \; | grep -v wp-login | grep -v ".png" | grep -v favicon |grep -v "login.php" > /path/to/log/

Find pour pull les dépots :

find . -mindepth 2 -maxdepth 2 -type d -print -exec git -C {} pull \;
Last updated on 25th May 2018