{"id":2726,"date":"2025-12-21T14:10:41","date_gmt":"2025-12-21T13:10:41","guid":{"rendered":"https:\/\/artheodoc.fr\/?page_id=2726"},"modified":"2025-12-21T14:10:41","modified_gmt":"2025-12-21T13:10:41","slug":"la-commande-cat-sous-linux","status":"publish","type":"page","link":"https:\/\/artheodoc.fr\/index.php\/la-commande-cat-sous-linux\/","title":{"rendered":"La commande cat sous Linux"},"content":{"rendered":"\n<p>Voici un tableau synth\u00e9tique documentant l&rsquo;utilisation de la commande cat sous Bash, avec ses principales options et cas d&rsquo;usage&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 d&rsquo;utlisiation<\/strong><\/th><\/tr><\/thead><tbody><tr><td>(sans option)<\/td><td>Affiche le contenu d&rsquo;un ou plusieurs fichiers sur la sortie standard.<\/td><td>cat fichier.txt<\/td><\/tr><tr><td><code>-n<\/code><\/td><td>Num\u00e9rote les lignes du fichier affich\u00e9.<\/td><td>cat -n fichier.txt<\/td><\/tr><tr><td><code>-b<\/code><\/td><td>Num\u00e9rote uniquement les lignes non vides.<\/td><td>cat -b fichier.txt<\/td><\/tr><tr><td><code>-s<\/code><\/td><td>Supprime les lignes vides cons\u00e9cutives (ne laisse qu&rsquo;une seule ligne vide).<\/td><td>cat -s fichier.txt<\/td><\/tr><tr><td><code>-A<\/code><\/td><td>Affiche les caract\u00e8res sp\u00e9ciaux (tabulations, fins de ligne, etc.).<\/td><td>cat -A fichier.txt<\/td><\/tr><tr><td><code>-v<\/code><\/td><td>Affiche les caract\u00e8res non imprimables (sauf tabulations et fins de ligne).<\/td><td>cat -v fichier.txt<\/td><\/tr><tr><td><code>-T<\/code><\/td><td>Affiche les tabulations comme ^I.<\/td><td>cat -T fichier.txt<\/td><\/tr><tr><td><code>-E<\/code><\/td><td>Affiche un $ \u00e0 la fin de chaque ligne.<\/td><td>cat -E fichier.txt<\/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<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 d&rsquo;utlisiation<\/strong><\/th><\/tr><\/thead><tbody><tr><td><code>&gt;<\/code><\/td><td>Redirige la sortie vers un fichier (\u00e9crase le fichier existant).<\/td><td>cat fichier1.txt &gt; fichier2.txt<\/td><\/tr><tr><td><code>&gt;&gt;<\/code><\/td><td>Redirige la sortie vers un fichier (ajoute \u00e0 la fin du fichier).<\/td><td>cat fichier1.txt &gt;&gt; fichier2.txt<\/td><\/tr><tr><td><code>&lt;<\/code><\/td><td>Lit l&rsquo;entr\u00e9e depuis un fichier (peu utilis\u00e9 avec cat).<\/td><td>cat &lt; fichier.txt (\u00e9quivalent \u00e0 cat fichier.txt)<\/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<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 d&rsquo;utlisiation<\/strong><\/th><\/tr><\/thead><tbody><tr><td>Concat\u00e9nation<\/td><td>Affiche le contenu de plusieurs fichiers \u00e0 la suite.<\/td><td>cat fichier1.txt fichier2.txt<\/td><\/tr><tr><td>Cr\u00e9ation<\/td><td>Cr\u00e9e un fichier vide ou \u00e9crase un fichier existant.<\/td><td>cat &gt; nouveau_fichier.txt (puis entrer du texte) &#8211; (Ctrl + D pour terminer.)<\/td><\/tr><tr><td>Ajout<\/td><td>Ajoute du texte \u00e0 la fin d&rsquo;un fichier existant.<\/td><td>cat &gt;&gt; fichier.txt (puis entrer du texte) &#8211; (Ctrl + D pour terminer.)<\/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<p class=\"has-large-font-size\">Remarques utiles&nbsp;:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>cat est souvent utilis\u00e9 pour afficher rapidement le contenu d&rsquo;un fichier ou pour concat\u00e9ner plusieurs fichiers.<\/li>\n\n\n\n<li>Pour les fichiers volumineux, pr\u00e9f\u00e9rez des outils comme less, more, ou head\/tail.<\/li>\n\n\n\n<li>cat peut aussi \u00eatre utilis\u00e9 dans des pipelines pour cha\u00eener des commandes (ex: <strong>cat fichier.txt | <a href=\"https:\/\/artheodoc.fr\/index.php\/la-commande-grep-sous-linux\/\" data-type=\"page\" data-id=\"2445\" target=\"_blank\" rel=\"noreferrer noopener\">grep<\/a> \u00ab\u00a0motif\u00a0\u00bb<\/strong>).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p>Sources&nbsp;: Le Chat Mistral<\/p>\n\n\n\n<p><a href=\"https:\/\/chat.mistral.ai\/chat\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/chat.mistral.ai\/chat<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voici un tableau synth\u00e9tique documentant l&rsquo;utilisation de la commande cat sous Bash, avec ses principales options et cas d&rsquo;usage&nbsp;: Option Description Exemple d&rsquo;utlisiation (sans option) Affiche le contenu d&rsquo;un ou plusieurs fichiers sur la sortie standard. cat fichier.txt -n Num\u00e9rote les lignes du fichier affich\u00e9. cat -n fichier.txt -b Num\u00e9rote uniquement les lignes non vides. [&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-2726","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/pages\/2726","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=2726"}],"version-history":[{"count":1,"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/pages\/2726\/revisions"}],"predecessor-version":[{"id":2727,"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/pages\/2726\/revisions\/2727"}],"wp:attachment":[{"href":"https:\/\/artheodoc.fr\/index.php\/wp-json\/wp\/v2\/media?parent=2726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}