{"id":2602,"date":"2025-07-18T14:18:33","date_gmt":"2025-07-18T13:18:33","guid":{"rendered":"https:\/\/workboot.fr\/ciela\/?page_id=2602"},"modified":"2025-10-29T18:28:53","modified_gmt":"2025-10-29T17:28:53","slug":"bash-shell-2","status":"publish","type":"page","link":"https:\/\/workboot.fr\/ciela\/bash-shell-2\/","title":{"rendered":"SCRIPT BASH SHELL"},"content":{"rendered":"\n<nav aria-label=\"Table des mati\u00e8res\" class=\"wp-block-table-of-contents\"><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/#l-interpreteur-bash\">l&rsquo;interpr\u00e9teur Bash<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/#premiere-ligne-de-script-shebang\">Premi\u00e8re ligne de script  (shebang)<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/#donner-le-droit-d-execution-au-script-shell\">Donner le droit d&rsquo;ex\u00e9cution au script shell<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/#true-false-et\">true false et $?<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/#true\">true<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/#false\">false<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/#ce-petit-test-demontre-comment-fonctionne\">Ce petit test d\u00e9montre comment $? fonctionne :<\/a><\/li><\/ol><\/li><\/ol><\/nav>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"l-interpreteur-bash\">l&rsquo;interpr\u00e9teur Bash<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Permet de coder rapidement des petits programmes en vue d&rsquo;administrer un syst\u00e8me linux. Nous allons d\u00e9couvrir ce langage: Un script shell bash se fera avec un \u00e9diteur de texte,, vi , vim, nano, gedit  ..etc ..<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C&rsquo;est un fichier compatible en code ASCII<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"premiere-ligne-de-script-shebang\">Premi\u00e8re ligne de script  (shebang)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">appel\u00e9 codet d\u00a0\u00bbinterpr\u00e9teur en fran\u00e7ais ou shebang  en anglais ou hashbang  (#!)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash&nbsp;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">la premi\u00e8re ligne sur Scrip Shell BASH, indique l&rsquo;interpr\u00e9teur du script   ici \/bin\/bash<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"donner-le-droit-d-execution-au-script-shell\">Donner le droit d&rsquo;ex\u00e9cution au script shell<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x programme.sh \n.\/programme.sh  <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">si on veut ex\u00e9cuter le code on peut l&rsquo;envoyer directement \u00e0 l\u2019interpr\u00e9teur .<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bash .\/programme.sh<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"true-false-et\">true false et $?<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">true est une fonction qui renvoie 0&nbsp; (ici vraie c&rsquo;est 0 et diff\u00e9rent c&rsquo;est faux) et false est une autre fonction qui renvoie 1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>true\necho $?\n0\nfalse\necho $?\n1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Explications:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"true\"><code>true<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Cette commande int\u00e9gr\u00e9e renvoie <strong>toujours un code de retour 0<\/strong>, ce qui signifie \u00ab\u202fsucc\u00e8s\u202f\u00bb.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo $?  # renvoie  0<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"false\"><code>false<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Cette commande int\u00e9gr\u00e9e renvoie <strong>toujours un code de retour 1<\/strong>, ce qui signifie \u00ab\u202f\u00e9chec\u202f\u00bb (ou plus g\u00e9n\u00e9ralement, \u00ab\u202ffaux\u202f\u00bb).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo $?  # renvoie  1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ce-petit-test-demontre-comment-fonctionne\">Ce petit test d\u00e9montre comment <code>$?<\/code> fonctionne :<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>0<\/code> signifie <strong>succ\u00e8s<\/strong> (vrai).<\/li>\n\n\n\n<li>Un entier non nul (souvent <code>1<\/code>) signifie <strong>\u00e9chec<\/strong> (faux).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">C\u2019est la base du contr\u00f4le de flux en shell, par exemple dans les instructions <code>if<\/code>, <code>while<\/code>, ou <code>&amp;&amp;<\/code>, <code>||<\/code>, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>l&rsquo;interpr\u00e9teur Bash Permet de coder rapidement des petits programmes en vue d&rsquo;administrer un syst\u00e8me linux. Nous allons d\u00e9couvrir ce langage: Un script shell bash se fera avec un \u00e9diteur de [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","_uag_custom_page_level_css":"","footnotes":""},"class_list":["post-2602","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SCRIPT BASH SHELL - workboot<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SCRIPT BASH SHELL - workboot\" \/>\n<meta property=\"og:description\" content=\"l&rsquo;interpr\u00e9teur Bash Permet de coder rapidement des petits programmes en vue d&rsquo;administrer un syst\u00e8me linux. Nous allons d\u00e9couvrir ce langage: Un script shell bash se fera avec un \u00e9diteur de [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/workboot.fr\/ciela\/bash-shell-2\/\" \/>\n<meta property=\"og:site_name\" content=\"workboot\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-29T17:28:53+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/bash-shell-2\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/bash-shell-2\\\/\",\"name\":\"SCRIPT BASH SHELL - workboot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\"},\"datePublished\":\"2025-07-18T13:18:33+00:00\",\"dateModified\":\"2025-10-29T17:28:53+00:00\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/workboot.fr\\\/ciela\\\/bash-shell-2\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#website\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"name\":\"workboot\",\"description\":\"Open Source, Open Minds \",\"publisher\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#organization\",\"name\":\"workboot\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"contentUrl\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/logo_ciel-dorian-1.png\",\"width\":1024,\"height\":950,\"caption\":\"workboot\"},\"image\":{\"@id\":\"https:\\\/\\\/workboot.fr\\\/ciela\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SCRIPT BASH SHELL - workboot","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/workboot.fr\/ciela\/bash-shell-2\/","og_locale":"fr_FR","og_type":"article","og_title":"SCRIPT BASH SHELL - workboot","og_description":"l&rsquo;interpr\u00e9teur Bash Permet de coder rapidement des petits programmes en vue d&rsquo;administrer un syst\u00e8me linux. Nous allons d\u00e9couvrir ce langage: Un script shell bash se fera avec un \u00e9diteur de [&hellip;]","og_url":"https:\/\/workboot.fr\/ciela\/bash-shell-2\/","og_site_name":"workboot","article_modified_time":"2025-10-29T17:28:53+00:00","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/workboot.fr\/ciela\/bash-shell-2\/","url":"https:\/\/workboot.fr\/ciela\/bash-shell-2\/","name":"SCRIPT BASH SHELL - workboot","isPartOf":{"@id":"https:\/\/workboot.fr\/ciela\/#website"},"datePublished":"2025-07-18T13:18:33+00:00","dateModified":"2025-10-29T17:28:53+00:00","inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/workboot.fr\/ciela\/bash-shell-2\/"]}]},{"@type":"WebSite","@id":"https:\/\/workboot.fr\/ciela\/#website","url":"https:\/\/workboot.fr\/ciela\/","name":"workboot","description":"Open Source, Open Minds ","publisher":{"@id":"https:\/\/workboot.fr\/ciela\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/workboot.fr\/ciela\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/workboot.fr\/ciela\/#organization","name":"workboot","url":"https:\/\/workboot.fr\/ciela\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/","url":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","contentUrl":"https:\/\/workboot.fr\/ciela\/wp-content\/uploads\/2025\/05\/logo_ciel-dorian-1.png","width":1024,"height":950,"caption":"workboot"},"image":{"@id":"https:\/\/workboot.fr\/ciela\/#\/schema\/logo\/image\/"}}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/workboot.fr\/ciela\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"l&rsquo;interpr\u00e9teur Bash Permet de coder rapidement des petits programmes en vue d&rsquo;administrer un syst\u00e8me linux. Nous allons d\u00e9couvrir ce langage: Un script shell bash se fera avec un \u00e9diteur de [&hellip;]","_links":{"self":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/comments?post=2602"}],"version-history":[{"count":3,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2602\/revisions"}],"predecessor-version":[{"id":4773,"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/pages\/2602\/revisions\/4773"}],"wp:attachment":[{"href":"https:\/\/workboot.fr\/ciela\/wp-json\/wp\/v2\/media?parent=2602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}