Find

De Linuxmemo.

(Différences entre les versions)
(Expression)
(Astuces)
Ligne 43 : Ligne 43 :
==Astuces==
==Astuces==
 +
*somme de taille de fichiers
  find . -iname "*.mkv" | xargs stat -c %s | awk '{a+=$1;print a}' |tail -1
  find . -iname "*.mkv" | xargs stat -c %s | awk '{a+=$1;print a}' |tail -1
-
Calcul de conversion:
+
*Calcul de conversion:
  kilobytes=$((bytes / 2**10))
  kilobytes=$((bytes / 2**10))
  megabytes=$((bytes / 2**20))
  megabytes=$((bytes / 2**20))
  gigabytes=$((bytes / 2**30))
  gigabytes=$((bytes / 2**30))

Version du 7 avril 2014 à 09:55


find [options] [starting path] [expression]
find . -type d -iname thumbs

options remarquables

-maxdepth 1

limite a partée 1 au répertoire courant (non récursif)

-iname "*.gz" 

recherche nominative insensible a la caste

-mtime +30

plus vieux de 30 jour (24h*30)

-exec rm -f {} \; 

suppression du résultat

-execdir cp {} /home/ \;
find . -iname "*.mkv" -execdir cp -v {} /mnt/popcorn/Video/MKV/ \;

Using both basename and full path in find -exec for cp

Expression

  • Force precedence
( expr )
  • négation
! expr
-not expr (not POSIX compliant.)
  • and
expr1 expr2
expr1 -a expr2
expr1 -and expr2 (not POSIX compliant.)
  • or
expr1 -or expr2
expr1 -o expr2 (not POSIX compliant.)
  • liste
expr1 , expr2

Astuces

  • somme de taille de fichiers
find . -iname "*.mkv" | xargs stat -c %s | awk '{a+=$1;print a}' |tail -1
  • Calcul de conversion:
kilobytes=$((bytes / 2**10))
megabytes=$((bytes / 2**20))
gigabytes=$((bytes / 2**30))
Outils personnels