{"id":2751,"date":"2025-12-23T17:24:24","date_gmt":"2025-12-23T16:24:24","guid":{"rendered":"https:\/\/artheodoc.fr\/?page_id=2751"},"modified":"2025-12-23T17:24:24","modified_gmt":"2025-12-23T16:24:24","slug":"rechercher-des-fichiers-avec-find","status":"publish","type":"page","link":"https:\/\/artheodoc.fr\/index.php\/rechercher-des-fichiers-avec-find\/","title":{"rendered":"Rechercher des fichiers avec find"},"content":{"rendered":"\n<p><strong>Utilisation<\/strong>\u00a0: Recherche de fichiers et dossiers en fonction de divers crit\u00e8res (nom, taille, date, permissions, etc.).<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Syntaxe de base<\/h1>\n\n\n\n<p>find [chemin] [options] [expression]<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Tableau r\u00e9capitulatif<\/h1>\n\n\n\n<p>Voici un tableau r\u00e9capitulatif des options les plus courantes de la commande find en Bash, avec des exemples d&rsquo;utilisation&nbsp;:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Option<\/strong><\/th><th><strong>Description<\/strong><\/th><th><strong>Exemple<\/strong><\/th><\/tr><\/thead><tbody><tr><td><code>-name<\/code><\/td><td>Recherche par nom de fichier (respecte la casse).<\/td><td>find \/dossier -name \u00ab\u00a0fichier.txt\u00a0\u00bb<\/td><\/tr><tr><td><code>-iname<\/code><\/td><td>Recherche par nom de fichier (insensible \u00e0 la casse).<\/td><td>find \/dossier -iname \u00ab\u00a0fichier.txt\u00a0\u00bb<\/td><\/tr><tr><td><code>-type<\/code><\/td><td>Filtre par type (f pour fichier, d pour dossier).<\/td><td>find \/dossier -type f (fichiers uniquement)<br>find \/dossier -type d (dossier uniquement)<\/td><\/tr><tr><td><code>-size<\/code><\/td><td>Filtre par taille (+ pour plus grand, &#8211; pour plus petit).<\/td><td>find \/dossier -size +10M (fichiers &gt; 10 Mo)<\/td><\/tr><tr><td><code>-mtime<\/code><\/td><td>Filtre par date de modification (en jours).<\/td><td>find \/dossier -mtime -7 (modifi\u00e9s il y a moins de 7 jours)<\/td><\/tr><tr><td><code>-atime<\/code><\/td><td>Filtre par date d&rsquo;acc\u00e8s (en jours).<\/td><td>find \/dossier -atime +30 (acc\u00e9d\u00e9s il y a plus de 30 jours)<\/td><\/tr><tr><td><code>-user<\/code><\/td><td>Filtre par propri\u00e9taire du fichier.<\/td><td>find \/dossier -user dominique<\/td><\/tr><tr><td><code>-group<\/code><\/td><td>Filtre par groupe propri\u00e9taire.<\/td><td>find \/dossier -group developers<\/td><\/tr><tr><td><code>-perm<\/code><\/td><td>Filtre par permissions (ex: 644, 755).<\/td><td>find \/dossier -perm 755<\/td><\/tr><tr><td><code>-exec<\/code><\/td><td>Ex\u00e9cute une commande sur les fichiers trouv\u00e9s.<\/td><td>find \/dossier -name \u00ab\u00a0*.tmp\u00a0\u00bb -exec rm {} \\; (supprime les fichiers .tmp)<\/td><\/tr><tr><td><code>-delete<\/code><\/td><td>Supprime les fichiers trouv\u00e9s (attention, irr\u00e9versible).<\/td><td>find \/dossier -name \u00ab\u00a0*.log\u00a0\u00bb -delete<\/td><\/tr><tr><td><code>-maxdepth<\/code><\/td><td>Limite la profondeur de recherche.<\/td><td>find \/dossier -maxdepth 2 -name \u00ab\u00a0fichier.txt\u00a0\u00bb<\/td><\/tr><tr><td><code>-mindepth<\/code><\/td><td>Ignore les niveaux de profondeur inf\u00e9rieurs.<\/td><td>find \/dossier -mindepth 2 -name \u00ab\u00a0fichier.txt\u00a0\u00bb<\/td><\/tr><tr><td><code>-not<\/code><\/td><td>Inverse la condition (exclut les fichiers correspondant au motif).<\/td><td>find \/dossier -not -name \u00ab\u00a0*.bak\u00a0\u00bb<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">Exemples combin\u00e9s<\/h1>\n\n\n\n<p>Pour rechercher tous les fichiers .txt modifi\u00e9s il y a moins de 3 jours et appartenant \u00e0 l&rsquo;utilisateur dominique&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">find \/home\/dominique -type f -name \"*.txt\" -mtime -3 -user dominique<\/pre>\n\n\n\n<p>Rechercher des fichiers modifi\u00e9s il y a moins de 7 jours&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">find . -type f -mtime -7<\/pre>\n\n\n\n<p>Rechercher des fichiers de plus de 10 Mo&nbsp;:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">find . -type f -size +10M<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">Exemples lors de l&rsquo;installation de serveurs<\/h1>\n\n\n\n<p>Changer les droits\/permissions en utilisant la r\u00e9cursivit\u00e9 seulement pour les dossiers\/fichiers en administrateur root.<\/p>\n\n\n\n<p>Exemple pour le dossier de Nextcloud.<\/p>\n\n\n\n<p><strong>d<\/strong> = dossier\/r\u00e9pertoire<\/p>\n\n\n\n<p><strong>f<\/strong> = fichier<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">find nextcloud\/ -type d -exec chmod 750 {} \\;<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">find nextcloud\/ -type f -exec chmod 640 {} \\;<\/pre>\n\n\n\n<p>Exemple pour WordPress (depuis le dossier d&rsquo;installation du site).<\/p>\n\n\n\n<p>. = dossier\/r\u00e9pertoire courant<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">find . -type d -exec chmod 0755 {} \\;<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">find . -type f -exec chmod 0644 {} \\;<\/pre>\n\n\n\n<p>Pour v\u00e9rifier le r\u00e9sultat.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ls -ls<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Utilisation\u00a0: Recherche de fichiers et dossiers en fonction de divers crit\u00e8res (nom, taille, date, permissions, etc.). Syntaxe de base find [chemin] [options] [expression] Tableau r\u00e9capitulatif Voici un tableau r\u00e9capitulatif des options les plus courantes de la commande find en Bash, avec des exemples d&rsquo;utilisation&nbsp;: Option Description Exemple -name Recherche par nom de fichier (respecte la [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-2751","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/pages\/2751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/comments?post=2751"}],"version-history":[{"count":1,"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/pages\/2751\/revisions"}],"predecessor-version":[{"id":2752,"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/pages\/2751\/revisions\/2752"}],"wp:attachment":[{"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/media?parent=2751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}