{"id":683,"date":"2020-08-07T10:41:43","date_gmt":"2020-08-07T08:41:43","guid":{"rendered":"http:\/\/rootfan.com\/?p=683"},"modified":"2023-04-23T22:48:23","modified_gmt":"2023-04-23T20:48:23","slug":"recherche-de-fichiers-texte-linux","status":"publish","type":"post","link":"https:\/\/rootfan.com\/fr\/find-text-files-linux\/","title":{"rendered":"Comment trouver du texte dans des fichiers sous Linux"},"content":{"rendered":"<p>Si vous souhaitez trouver un texte sp\u00e9cifique dans un r\u00e9pertoire donn\u00e9 de mani\u00e8re r\u00e9cursive, la meilleure fa\u00e7on de proc\u00e9der est d'utiliser la commande grep et un motif.<\/p>\n\n\n\n<p>C'est comme \u00e7a :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngrep -ri something *\n<\/pre><\/div>\n\n\n<p>-r ou -R est r\u00e9cursif,<br>-i pour ignorer le cas<br>-w signifie que le mot entier doit \u00eatre pris en compte.<br>-l (L minuscule) peut \u00eatre ajout\u00e9 pour ne donner que le nom des fichiers correspondants.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>En outre, les drapeaux -exclude, -include, -exclude-dir peuvent \u00eatre utilis\u00e9s pour une recherche efficace.<\/p>\n\n\n\n<p>La recherche ne portera que sur les fichiers portant l'extension .c ou .h :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngrep \u2013include=\\*.{c,h} -rnw '\/path\/to\/somewhere\/' -e \"pattern\"\n<\/pre><\/div>\n\n\n<p>Cela exclura la recherche de tous les fichiers se terminant par l'extension .o :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngrep \u2013exclude=*.o -rnw '\/path\/to\/somewhere\/' -e \"pattern\"\n<\/pre><\/div>\n\n\n<p>Pour les r\u00e9pertoires, il est possible d'exclure un ou plusieurs r\u00e9pertoires particuliers gr\u00e2ce au param\u00e8tre -exclude-dir.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ngrep \u2013exclude-dir={dir1,dir2,*.dst} -rnw '\/path\/to\/somewhere\/' -e \"pattern\"\n<\/pre><\/div>\n\n\n<p>Pour plus d'options, voir man grep.<\/p>","protected":false},"excerpt":{"rendered":"<p>Si vous souhaitez trouver un texte sp\u00e9cifique dans un r\u00e9pertoire donn\u00e9 de mani\u00e8re r\u00e9cursive, la meilleure fa\u00e7on de le faire est d'utiliser la commande grep et un motif. C'est comme \u00e7a : -r ou -R est r\u00e9cursif,-i pour ignorer la casse-w pour rechercher le mot entier.-l (L minuscule) peut \u00eatre ajout\u00e9 pour ne donner que le fichier ... <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/rootfan.com\/fr\/find-text-files-linux\/\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de \" Comment trouver du texte dans des fichiers sous Linux \"<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":2913,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_focus_keyword":"","rank_math_title":"","rank_math_description":"Master the art of finding specific text within files on Linux using efficient and powerful search techniques.","rank_math_robots":null,"rank_math_og_title":"","rank_math_og_description":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[47],"tags":[15,48,35,49],"class_list":["post-683","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-files","tag-grep","tag-linux","tag-text"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/rootfan.com\/wp-content\/uploads\/pexels-photo-2531608.jpeg?fit=1880%2C1253&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/posts\/683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/comments?post=683"}],"version-history":[{"count":14,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":5410,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/posts\/683\/revisions\/5410"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/media\/2913"}],"wp:attachment":[{"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/media?parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rootfan.com\/fr\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}