{"id":16366,"date":"2023-08-16T06:50:07","date_gmt":"2023-08-16T06:50:07","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=16366"},"modified":"2024-01-18T11:35:56","modified_gmt":"2024-01-18T11:35:56","slug":"bash-boolean-variable","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/","title":{"rendered":"What is Boolean Variable in Bash? [3 Cases With Examples]"},"content":{"rendered":"<p style=\"text-align: justify;\">Boolean variables serve as the essential tool for creating flexible, dynamic, and condition-driven Bash scripts. These variables empower users to make Bash scripts that are evenly responsive to the changing environment &amp; user interactions. In this guide, I\u2019ll demonstrate the adaptable context of <strong>Bash Boolean variables<\/strong> for different cases.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Key_Takeaways\" >Key Takeaways<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Free_Downloads\" >Free Downloads<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#What_Are_Bash_Boolean_Variables\" >What Are Bash Boolean Variables?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#3_Cases_for_Assigning_Boolean_Variables_in_Bash\" >3 Cases for Assigning Boolean Variables in Bash<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Case_1_Assigning_Bash_Boolean_Variables_Using_Strings\" >Case 1: Assigning Bash Boolean Variables Using Strings<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Case_2_Assigning_Bash_Boolean_Variables_Using_Integers\" >Case 2: Assigning Bash Boolean Variables Using Integers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Case_3_Assigning_Bash_Boolean_Variables_Using_Variable_Names_Directly\" >Case 3: Assigning Bash Boolean Variables Using Variable Names Directly<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#5_Examples_of_Using_Boolean_Variables_in_Bash\" >5 Examples of Using Boolean Variables in Bash<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Example_1_Bash_Boolean_Variable_in_Nested_Conditional_Statements\" >Example 1: Bash Boolean Variable in Nested Conditional Statements<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Example_2_Bash_Boolean_Variable_With_Logical_Operators\" >Example 2: Bash Boolean Variable With Logical Operators<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Example_3_Bash_Boolean_Variable_Within_Case_Statements\" >Example 3: Bash Boolean Variable Within Case Statements<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Example_4_Bash_Boolean_Variable_for_Loop_Control\" >Example 4: Bash Boolean Variable for Loop Control<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Example_5_Reading_Validating_Boolean_Input_From_Users\" >Example 5: Reading &amp; Validating Boolean Input From Users<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#People_Also_Ask\" >People Also Ask<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Key_Takeaways\"><\/span>Key Takeaways<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>Learning about Bash Boolean variables.<\/li>\n<li>Experiencing Boolean variables for different cases in Bash.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Free_Downloads\"><\/span>Free Downloads<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Practice-Files_Bash-Boolean-Variable.zip\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#E8F9FF;border-color:#bac8cc;border-radius:56px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:8px 26px;font-size:20px;line-height:30px;border-color:#effbff;border-radius:56px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:20px;color:#1AA1D6\"><\/i> Download the Practice Files<\/span><\/a><\/div>\n<h3><span class=\"ez-toc-section\" id=\"What_Are_Bash_Boolean_Variables\"><\/span>What Are Bash Boolean Variables?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><strong>Boolean variables<\/strong> are the crucial variables in Bash that contain only two possible conditions i.e., <strong>true <\/strong>or <strong>false <\/strong>for decision-making. Actually, Bash does not include the Boolean data type itself, instead, the users have to simulate these variables by using strings, integers, or by appending variable names directly in conditionals. With the explicit decision-driven capability, <strong>Bash Boolean variables<\/strong> enable users to control the flow of a Bash program very efficaciously.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"3_Cases_for_Assigning_Boolean_Variables_in_Bash\"><\/span>3 Cases for Assigning Boolean Variables in Bash<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can declare and then assign values to the Boolean variables in Bash. To represent the variables you can use strings (\u2018<strong>true<\/strong>\u2019 or \u2018<strong>false<\/strong>\u2019) or integers (<strong>0 <\/strong>for <strong>false <\/strong>or <strong>true <\/strong>for <strong>otherwise<\/strong>) or the variable names directly. I have described three cases below to assign the Boolean variables in Bash:<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Case_1_Assigning_Bash_Boolean_Variables_Using_Strings\"><\/span>Case 1: Assigning Bash Boolean Variables Using Strings<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Follow the steps below if you want to assign Bash Boolean variables using string values:<\/p>\n<p><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p><a id=\"steps-1-and-2\"><\/a>\u278a Open your <strong>Ubuntu <\/strong><a href=\"https:\/\/linuxsimply.com\/what-is-terminal-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>Terminal<\/strong><\/a>.<\/p>\n<p>\u278b To open a script in the <a href=\"https:\/\/linuxsimply.com\/nano-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>nano<\/strong><\/a> text editor, write the command below:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">nano string.sh<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<ul>\n<li><strong>nano<\/strong>: A text editor.<\/li>\n<li><strong>string.sh<\/strong>: This is a script. Here, I have named the script <strong>\u2018string.sh\u2019<\/strong>. You can name any of your choices.<\/li>\n<\/ul>\n<\/div><\/div>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-16411\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img1-Opening-the-file-in-Nano-editor.png\" alt=\"Opening the file in Nano text editor\" width=\"700\" height=\"139\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img1-Opening-the-file-in-Nano-editor.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img1-Opening-the-file-in-Nano-editor-300x60.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img1-Opening-the-file-in-Nano-editor-765x152.png 765w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>\u278c Hereafter, write the following script inside the editor:<\/p>\n<p><span style=\"color: #800080;\"><strong>Script (string.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Assigning boolean variables using strings\nis_active=&quot;true&quot;\nis_admin=&quot;false&quot;<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">In <strong>#!\/bin\/bash<\/strong>, \u2018<strong>#!<\/strong>\u2019 is called \u2018<strong>Shebang<\/strong>\u2019 or \u2018<strong>Hashbang<\/strong>\u2019. In \u2018<strong>is_active=&#8221;true&#8221;<\/strong>\u2019, the value to the Boolean variable <strong>is_active <\/strong>is assigned to <strong>true <\/strong>representing the system is active. Also, in \u2018<strong>is_admin=&#8221;false&#8221;<\/strong>\u2019, the value to the Boolean variable <strong>is_admin <\/strong>is assigned to <strong>false <\/strong>representing the user is not an admin.<\/p>\n<\/div><\/div>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-16413\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img2-Assigning-boolean-variables-using-strings.png\" alt=\"Assigning Boolean variables using strings\" width=\"700\" height=\"214\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img2-Assigning-boolean-variables-using-strings.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img2-Assigning-boolean-variables-using-strings-300x92.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img2-Assigning-boolean-variables-using-strings-765x234.png 765w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>From the image, you can see that I have assigned string values to the Boolean variables.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Case_2_Assigning_Bash_Boolean_Variables_Using_Integers\"><\/span>Case 2: Assigning Bash Boolean Variables Using Integers<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Another way of assigning Boolean variables is to use integer values. Here\u2019s how to assign Bash Boolean Variables using integers:<\/p>\n<p><span style=\"color: #800080;\"><strong>Script (integer.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Assigning boolean variables using integers\nis_logged_in=5\nhas_permission=20<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">In \u2018<strong>is_logged_in=5<\/strong>\u2019, the integer value 5 is assigned to the variable <strong>is_logged_in<\/strong> indicating a non-zero integer that is considered true. Also, in \u2018<strong>has_permission=20<\/strong>\u2019, the integer value 20 is assigned to the variable <strong>has_permission<\/strong> which is also considered true.<\/p>\n<\/div><\/div>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-16414\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img3-Assigning-boolean-variables-using-integers.png\" alt=\"Assigning Boolean variables using integers\" width=\"700\" height=\"217\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img3-Assigning-boolean-variables-using-integers.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img3-Assigning-boolean-variables-using-integers-300x93.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img3-Assigning-boolean-variables-using-integers-768x238.png 768w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>From the image, you can see that I have assigned integer values to the Boolean variables.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Case_3_Assigning_Bash_Boolean_Variables_Using_Variable_Names_Directly\"><\/span>Case 3: Assigning Bash Boolean Variables Using Variable Names Directly<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">You can use variable names directly within conditionals as Boolean values. Here\u2019s a similar approach to the Bash Boolean Variables assignment:<\/p>\n<p><span style=\"color: #800080;\"><strong>Script (direct.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Assigning boolean variables using variable names directly\nis_logged_in=true\nhas_permission=false<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">Here, in \u2018<strong>is_logged_in=true<\/strong>\u2019 &amp; \u2018<strong>has_permission=false<\/strong>\u2019, the variable names <strong>is_logged_in<\/strong> &amp; <strong>has_permission <\/strong>are directly assigned as Boolean values.<\/p>\n<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16417\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img4-Assigning-boolean-variables-using-variable-names-directly.png\" alt=\"Assigning Boolean variables using variable names directly\" width=\"825\" height=\"224\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img4-Assigning-boolean-variables-using-variable-names-directly.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img4-Assigning-boolean-variables-using-variable-names-directly-300x81.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img4-Assigning-boolean-variables-using-variable-names-directly-766x208.png 766w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p>From the image, you can see that I have assigned the variable names as the Boolean values directly.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"5_Examples_of_Using_Boolean_Variables_in_Bash\"><\/span>5 Examples of Using Boolean Variables in Bash<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">You can use Bash Boolean variables to declare, manipulate, and evaluate variables that specify only two conditions: <strong>true <\/strong>or <strong>false<\/strong>. Here are some examples of using Boolean variables in Bash:<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_1_Bash_Boolean_Variable_in_Nested_Conditional_Statements\"><\/span>Example 1: Bash Boolean Variable in Nested Conditional Statements<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Typically, you can use Boolean variables in nested conditional statements. A similar demonstration is given below:<\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #800080;\"><strong>Steps to Follow &gt;<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">\u278a Repeat <a href=\"#steps-1-and-2\"><strong>steps 1 &amp; 2 of case 1 of assigning Bash Boolean variables<\/strong><\/a>\u00a0and write the following script inside the editor:<\/p>\n<p><span style=\"color: #800080;\"><strong>Script (conditional.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nis_it_sunny=false\nenjoying=true\n\nif $is_it_sunny; then\nif $enjoying; then\necho &quot;Today is a sunny day and I&#039;m enjoying it.&quot;\nelse\necho &quot;Today is a sunny day and I&#039;m not enjoying.&quot;\nfi\nelse\necho &quot;It&#039;s raining outside and I&#039;m enjoying the rain!&quot;\nfi<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">Here, \u2018<strong>is_it_sunny=false<\/strong>\u2019 &amp; \u2018<strong>enjoying=true<\/strong>\u2019 specify two Boolean variables with the assigned value \u2018<strong>false<\/strong>\u2019. The script uses nested conditional statements. The outer \u2018<strong>if<\/strong>\u2019 statement checks if the \u2018<strong>is_it_sunny<\/strong>\u2019 variable is true. If it becomes true, then it enters into the inner \u2018<strong>if<\/strong>\u2019 statement to check if the \u2018<strong>enjoying<\/strong>\u2019 is true.<\/p>\n<p style=\"text-align: justify;\">If the \u2018<strong>enjoying<\/strong>\u2019 variable is true, the <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/input-output\/output\/echo-command\/\" target=\"_blank\" rel=\"noopener\"><strong>echo command<\/strong><\/a> prints \u2018<strong>&#8220;Today is a sunny day and I&#8217;m enjoying it.&#8221;<\/strong>\u2019, or if the \u2018<strong>enjoying<\/strong>\u2019 variable is false, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;Today is a sunny day and I&#8217;m not enjoying.&#8221;<\/strong>\u2019. However, if the \u2018<strong>is_it_sunny<\/strong>\u2019 variable is false, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;It&#8217;s raining outside and I&#8217;m enjoying the rain!&#8221;<\/strong>\u2019.<\/p>\n<\/div><\/div>\n<p><a id=\"steps-2-and-3\"><\/a>\u278b Then, press <strong>CTRL+S<\/strong> to save the file &amp; press <strong>CTRL+X <\/strong>to exit.<\/p>\n<p>\u278c After that, use the command below to make the<strong> script<\/strong> executable:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">chmod u+x conditional.sh<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<ul>\n<li><a href=\"https:\/\/linuxsimply.com\/chmod-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>chmod<\/strong><\/a><strong>: <\/strong>Changes the permission of the files and directories.<\/li>\n<li><strong>u+x: <\/strong>Adds the executable permission for the user.<\/li>\n<li><strong>conditional.sh: <\/strong>The file which you want to make executable.<\/li>\n<\/ul>\n<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16419\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img5-Adding-executable-permission-to-the-script.png\" alt=\"Adding executable permission to the script\" width=\"700\" height=\"147\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img5-Adding-executable-permission-to-the-script.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img5-Adding-executable-permission-to-the-script-300x63.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img5-Adding-executable-permission-to-the-script-767x161.png 767w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>\u278d Finally, run the script by the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">.\/conditional.sh<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16421\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img6-Output-of-boolean-variables-in-conditionals.png\" alt=\"Output of Boolean variables in conditionals\" width=\"825\" height=\"195\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img6-Output-of-boolean-variables-in-conditionals.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img6-Output-of-boolean-variables-in-conditionals-300x71.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img6-Output-of-boolean-variables-in-conditionals-766x181.png 766w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p>In the above image, you can see the output of the matched condition.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_2_Bash_Boolean_Variable_With_Logical_Operators\"><\/span>Example 2: Bash Boolean Variable With Logical Operators<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>A simple example of Boolean variables with logical operators is given below:<\/p>\n<p style=\"text-align: justify;\"><div class=\"su-note\"  style=\"border-color:#e5e5e5;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#ffffff;border-color:#ffffff;color:#333333;\">You can follow <a href=\"#steps-2-and-3\"><strong>steps 2 &amp; 3 of example 1<\/strong><\/a>, to save &amp; make the script executable.<\/div><\/div>\n<p><span style=\"color: #800080;\"><strong>Script (logic.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Applying logical OR with boolean variables\n\nis_vip_member=true\nhas_free_offer=true\n\nif $is_vip_member || $has_free_offer; then\necho &quot;Either you are vip member or you have free offer.&quot;\nfi\n\n#Applying logical AND and NOT with boolean variables\n\nis_active=true\nhas_permission=false\n\nif $is_active &amp;&amp; ! $has_permission; then\necho &quot;Your account is active but you have no permission.&quot;\nfi<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">Here, the values of two Boolean variables \u2018<strong>is_vip_member=true<\/strong>\u2019 and \u2018<strong>has_free_offer=true<\/strong>\u2019 are set to <strong>true<\/strong>. The <strong>if <\/strong>statement checks if the two variables are true by using the logical operator <strong>OR (||)<\/strong>. If any of these two conditions become true, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;Either you are vip member or you have free offer.&#8221;<\/strong>\u2019.<\/p>\n<p style=\"text-align: justify;\">Again, the values of two boolean variables \u2018<strong>is_active=true<\/strong>\u2019 and \u2018<strong>has_permission=false<\/strong>\u2019 are set to <strong>true <\/strong>and <strong>false <\/strong>accordingly. Here, the <strong>if <\/strong>statement checks if <strong>is_active <\/strong>variable is true and <strong>has_permission <\/strong>is false by using the two logical operators <strong>AND (&amp;&amp;)<\/strong> and <strong>NOT (!)<\/strong>. If it matches, then the <strong>echo <\/strong>command prints \u2018<strong>&#8220;Your account is active but you have no permission.&#8221;<\/strong>\u2019.<\/p>\n<\/div><\/div>\n<p>Now, run the script by the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">.\/logic.sh<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16425\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img7-Output-of-boolean-variables-with-logical-operators.png\" alt=\"Output of Boolean variables with logical operators\" width=\"825\" height=\"238\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img7-Output-of-boolean-variables-with-logical-operators.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img7-Output-of-boolean-variables-with-logical-operators-300x87.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img7-Output-of-boolean-variables-with-logical-operators-766x221.png 766w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p>The above snapshot depicts the outputs of the Boolean variables with the logical operators <strong>AND<\/strong>, <strong>OR<\/strong>, and <strong>NOT<\/strong>.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_3_Bash_Boolean_Variable_Within_Case_Statements\"><\/span>Example 3: Bash Boolean Variable Within Case Statements<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The following example demonstrates how you can use Bash Boolean variables in nested case statements to handle multiple combinations:<\/p>\n<p style=\"text-align: justify;\"><div class=\"su-note\"  style=\"border-color:#e5e5e5;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#ffffff;border-color:#ffffff;color:#333333;\">You can follow <a href=\"#steps-2-and-3\"><strong>steps 2 &amp; 3 of example 1<\/strong><\/a>, to save &amp; make the script executable.<\/div><\/div>\n<p><span style=\"color: #800080;\"><strong>Script (case.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nage=15\nget_vaccine=true\n\ncase $get_vaccine in\ntrue)\ncase $age in\n[0-14])\necho &quot;You are not allowed for the vaccine.&quot;\n;;\n*)\necho &quot;You are allowed for the vaccine.&quot;\n;;\nesac\n;;\nfalse)\necho &quot;You must be vaccinated to enter here.&quot;\n;;\nesac<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">Here, two values <strong>15 <\/strong>and <strong>true <\/strong>are assigned respectively to the Boolean variables \u2018<strong>age<\/strong>\u2019 &amp; \u2018<strong>get_vaccine<\/strong>\u2019. The outer <strong>case <\/strong>statement checks if the value of \u2018<strong>get_vaccine<\/strong>\u2019 is true. If true, the inner <strong>case <\/strong>statement checks the \u2018<strong>age<\/strong>\u2019 variable. When \u2018<strong>age<\/strong>\u2019 is between 0-14, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;You are not allowed for the vaccine.&#8221;<\/strong>\u2019. If \u2018<strong>age<\/strong>\u2019 is more than 14, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;You are allowed for the vaccine.&#8221;<\/strong>\u2019. Now, if \u2018<strong>get_vaccine<\/strong>\u2019 is false, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;You must be vaccinated to enter here.&#8221;<\/strong>\u2019.<\/p>\n<\/div><\/div>\n<p>Now, run the script by the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">.\/case.sh<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16428\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img8-Output-of-boolean-variables-within-case-statements.png\" alt=\"Output of Boolean variables within case statements\" width=\"700\" height=\"201\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img8-Output-of-boolean-variables-within-case-statements.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img8-Output-of-boolean-variables-within-case-statements-300x86.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img8-Output-of-boolean-variables-within-case-statements-766x220.png 766w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>From the image, you can see the output of the Boolean variables within the case statements.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_4_Bash_Boolean_Variable_for_Loop_Control\"><\/span>Example 4: Bash Boolean Variable for Loop Control<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can control an infinite loop by using the Bash Boolean variables. Here\u2019s an example:<\/p>\n<p style=\"text-align: justify;\"><div class=\"su-note\"  style=\"border-color:#e5e5e5;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#ffffff;border-color:#ffffff;color:#333333;\">You can follow <a href=\"#steps-2-and-3\"><strong>steps 2 &amp; 3 of example 1<\/strong><\/a>, to save &amp; make the script executable.<\/div><\/div>\n<p><span style=\"color: #800080;\"><strong>Script (loop.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nloop_running=true\ncount=1\n\nwhile $loop_running; do\necho &quot;Student: $count&quot;\ncount=$((count + 1))\n\nif [ $count -eq 6 ]; then\nloop_running=false\necho &quot;End of the students&#039; loop.&quot;\nfi\ndone<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">Here, two variables \u2018<strong>loop_running<\/strong>\u2019 &amp; \u2018<strong>count<\/strong>\u2019 are assigned two values <strong>true <\/strong>&amp; <strong>1 <\/strong>respectively. Now, the <strong>while <\/strong>loop iterates until the \u2018<strong>loop_running<\/strong>\u2019 variable is true. Inside the loop, the <strong>echo <\/strong>command prints the current student count using the \u2018<strong>count<\/strong>\u2019 variable. Next, \u2018<strong>count=$((count + 1))<\/strong>\u2019 indicates the increment of the \u2018<strong>count<\/strong>\u2019 variable by 1.<\/p>\n<p style=\"text-align: justify;\">In the line \u2018<strong>if [ $count -eq 6 ]; then<\/strong>\u2019, the <strong>if <\/strong>statement checks if the value of \u2018<strong>count<\/strong>\u2019 equals 6. When the \u2018<strong>count<\/strong>\u2019 becomes 6, it sets \u2018<strong>loop_running<\/strong>\u2019 to false and stops the loop to iterate after 5 times (1-5). Then, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;End of the students&#8217; loop.&#8221;<\/strong>\u2019.<\/p>\n<\/div><\/div>\n<p>Now, run the script by the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">.\/loop.sh<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16430\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img9-Output-of-boolean-variables-for-loop-control.png\" alt=\"Output of Boolean variables for loop control\" width=\"700\" height=\"322\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img9-Output-of-boolean-variables-for-loop-control.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img9-Output-of-boolean-variables-for-loop-control-300x138.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img9-Output-of-boolean-variables-for-loop-control-767x353.png 767w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>The screenshot above dictates a loop of students which I have limited using the Boolean variables.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Example_5_Reading_Validating_Boolean_Input_From_Users\"><\/span>Example 5: Reading &amp; Validating Boolean Input From Users<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can easily read and validate Boolean inputs from users and respond properly according to the inputs.<\/p>\n<p style=\"text-align: justify;\"><div class=\"su-note\"  style=\"border-color:#e5e5e5;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#ffffff;border-color:#ffffff;color:#333333;\">You can follow <a href=\"#steps-2-and-3\"><strong>steps 2 &amp; 3 of example 1<\/strong><\/a>, to save &amp; make the script executable.<\/div><\/div>\n<p><span style=\"color: #800080;\"><strong>Script (input.sh) &gt;<\/strong><\/span><\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nread -p &quot;Are you ready to continue? (yes\/no): &quot; user_input\nif [ &quot;$user_input&quot; = &quot;yes&quot; ]; then\necho &quot;User is ready to continue.&quot;\nelse\necho &quot;User is not ready to continue.&quot;\nfi<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">In \u2018<strong>read -p &#8220;Are you ready to continue? (yes\/no): &#8221; user_input<\/strong>\u2019, the <strong>read <\/strong>command prompts the user input, the \u2018<strong>-p<\/strong>\u2019 flag provides the prompt to the user, and the input is stored in \u2018<strong>user_input<\/strong>\u2019 variable. Then, in \u2018<strong>if [ &#8220;$user_input&#8221; = &#8220;yes&#8221; ]; then<\/strong>\u2019, the <strong>if <\/strong>statement checks if the \u2018<strong>user_input<\/strong>\u2019 variable is yes. Now, if the \u2018<strong>user_input<\/strong>\u2019 is <strong>yes<\/strong>, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;User is ready to continue.&#8221;<\/strong>\u2019, or if the \u2018<strong>user_input<\/strong>\u2019 is <strong>no<\/strong>, the <strong>echo <\/strong>command prints \u2018<strong>&#8220;User is not ready to continue.&#8221;<\/strong>\u2019.<\/p>\n<\/div><\/div>\n<p>Now, run the script by the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">.\/input.sh<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16432\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img10-Output-of-reading-validating-boolean-input-from-users.png\" alt=\"Output of reading &amp; validating Boolean input from users\" width=\"825\" height=\"294\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img10-Output-of-reading-validating-boolean-input-from-users.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img10-Output-of-reading-validating-boolean-input-from-users-300x107.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/img10-Output-of-reading-validating-boolean-input-from-users-766x273.png 766w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p>The above image illustrates different outputs according to the response of the different user inputs.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Boolean variables are a versatile approach to control the flow of scripts in Bash. By using these variables effectively, you can append various tasks and make decisions based on different conditions regarding your script.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"People_Also_Ask\"><\/span>People Also Ask<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"su-accordion su-u-trim\">\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>How much data does Boolean variable contain?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">A Boolean variable contains two types of data: <strong>1(true)<\/strong> and <strong>0(false)<\/strong>.<\/div><\/div>\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>Does a Boolean variable support integer values?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"><strong>Yes<\/strong>, a Boolean variable supports not only integer values but also string values.<\/div><\/div>\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>Can I use variable names as Boolean values directly?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"><strong>Yes<\/strong>, you can use variable names within conditionals directly as Boolean values.<\/div><\/div>\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>Can I use Boolean flags to control loop behavior in Bash?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"><strong>Of course<\/strong>, you can use Boolean flags serving as Boolean variables to control loop behavior in Bash.<\/div><\/div>\n<p style=\"text-align: justify;\"><div class=\"su-spoiler su-spoiler-style-fancy su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span><strong>Can I simulate Boolean conditions within case statements?<\/strong><\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"><strong>Yes<\/strong>, you can simulate Boolean conditions within case statements by using the matched patterns of the Boolean variables.<\/div><\/div>\n<\/div>\n<p><span style=\"font-size: 18pt; color: #003366;\"><strong>Related Articles<\/strong><\/span><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/built-in-variables\/\" target=\"_blank\" rel=\"noopener\">What Are Built-in Variables in Bash [2 Cases With Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/environment-variables\/\" target=\"_blank\" rel=\"noopener\">An Ultimate Guide of Using Bash Environment Variables<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/bashrc-environment-variable\/\" target=\"_blank\" rel=\"noopener\">The \u201c.bashrc\u201d Environment Variables [4 Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/string-variable\/\" target=\"_blank\" rel=\"noopener\">String Variables in Bash [Manipulation, Interpolation &amp; Testing]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/array-variable\/\" target=\"_blank\" rel=\"noopener\">What is Variable Array in Bash? [4 Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/special-variables\/\" target=\"_blank\" rel=\"noopener\">An Extensive Exploration of Bash Special Variables [9 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/heredoc-variable\/\" target=\"_blank\" rel=\"noopener\">What is HereDoc Variable in Bash? [5 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/ps1\/\" target=\"_blank\" rel=\"noopener\">What is PS1 Variable in Bash? [3 Customization Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/ps3\/\" target=\"_blank\" rel=\"noopener\">What is PS3 Variable in Bash? [3 Practical Examples]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<p><strong>&lt;&lt; Go Back to <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Types of Variables in Bash&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1065857,&quot;3&quot;:{&quot;1&quot;:0},&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/\" target=\"_blank\" rel=\"noopener\">Types of Variables in Bash<\/a><\/span> | <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Variable&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:16768,&quot;10&quot;:1,&quot;11&quot;:4,&quot;17&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/\" target=\"_blank\" rel=\"noopener\">Bash Variables<\/a><\/span> | <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a><\/strong><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-center kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;center&quot;,&quot;id&quot;:&quot;16366&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;What is Boolean Variable in Bash? [3 Cases With Examples]&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\">Rate this post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Boolean variables serve as the essential tool for creating flexible, dynamic, and condition-driven Bash scripts. These variables empower users to &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"What is Boolean Variable in Bash? [3 Cases With Examples]\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#more-16366\" aria-label=\"Read more about What is Boolean Variable in Bash? [3 Cases With Examples]\">Read more<\/a><\/p>\n","protected":false},"author":314905,"featured_media":16399,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[120],"class_list":["post-16366","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-variable-types","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is Boolean Variable in Bash? [3 Cases With Examples]<\/title>\n<meta name=\"description\" content=\"Use the Boolean variable in Bash to create more versatile, responsive, and condition-driven scripts by handling a wide range of scenarios.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Boolean Variable in Bash? [3 Cases With Examples]\" \/>\n<meta property=\"og:description\" content=\"Use the Boolean variable in Bash to create more versatile, responsive, and condition-driven scripts by handling a wide range of scenarios.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/nadiba.rahman?mibextid=ZbWKwL\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-16T06:50:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-18T11:35:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Feature-image-Bash-boolean-variable.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nadiba Rahman\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nadiba Rahman\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/\"},\"author\":{\"name\":\"Nadiba Rahman\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/69b717a03a5d9dc48e683aaffe22d33f\"},\"headline\":\"What is Boolean Variable in Bash? [3 Cases With Examples]\",\"datePublished\":\"2023-08-16T06:50:07+00:00\",\"dateModified\":\"2024-01-18T11:35:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/\"},\"wordCount\":1955,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/Feature-image-Bash-boolean-variable.png\",\"keywords\":[\"variable types\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/\",\"name\":\"What is Boolean Variable in Bash? [3 Cases With Examples]\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/Feature-image-Bash-boolean-variable.png\",\"datePublished\":\"2023-08-16T06:50:07+00:00\",\"dateModified\":\"2024-01-18T11:35:56+00:00\",\"description\":\"Use the Boolean variable in Bash to create more versatile, responsive, and condition-driven scripts by handling a wide range of scenarios.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/Feature-image-Bash-boolean-variable.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/Feature-image-Bash-boolean-variable.png\",\"width\":400,\"height\":400,\"caption\":\"Feature image-Bash Boolean variable\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/boolean-variables\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bash Scripting Tutorial\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bash Variables\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Types of Variables in Bash\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/variables\\\/types\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"What is Boolean Variable in Bash? [3 Cases With Examples]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"name\":\"LinuxSimply\",\"description\":\"All About Linux\",\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/linuxsimply.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\",\"name\":\"LinuxSimply\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"width\":355,\"height\":48,\"caption\":\"LinuxSimply\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/69b717a03a5d9dc48e683aaffe22d33f\",\"name\":\"Nadiba Rahman\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Nadiba-Rahman-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Nadiba-Rahman-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Nadiba-Rahman-II-96x96.png\",\"caption\":\"Nadiba Rahman\"},\"description\":\"Hello, This is Nadiba Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation with a bachelor\u2019s degree in Electronics &amp; Telecommunication Engineering from Rajshahi University of Engineering &amp; Technology (RUET).I am quite passionate about crafting. I really adore exploring and learning new things which always helps me to think transparently. And this curiosity led me to pursue knowledge about Linux. My goal is to portray Linux-based practical problems and share them with you. Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/nadiba.rahman?mibextid=ZbWKwL\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/nadiba-rahman-443459171\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/nadiba\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Boolean Variable in Bash? [3 Cases With Examples]","description":"Use the Boolean variable in Bash to create more versatile, responsive, and condition-driven scripts by handling a wide range of scenarios.","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:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/","og_locale":"en_US","og_type":"article","og_title":"What is Boolean Variable in Bash? [3 Cases With Examples]","og_description":"Use the Boolean variable in Bash to create more versatile, responsive, and condition-driven scripts by handling a wide range of scenarios.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/nadiba.rahman?mibextid=ZbWKwL","article_published_time":"2023-08-16T06:50:07+00:00","article_modified_time":"2024-01-18T11:35:56+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Feature-image-Bash-boolean-variable.png","type":"image\/png"}],"author":"Nadiba Rahman","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nadiba Rahman","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/"},"author":{"name":"Nadiba Rahman","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/69b717a03a5d9dc48e683aaffe22d33f"},"headline":"What is Boolean Variable in Bash? [3 Cases With Examples]","datePublished":"2023-08-16T06:50:07+00:00","dateModified":"2024-01-18T11:35:56+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/"},"wordCount":1955,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Feature-image-Bash-boolean-variable.png","keywords":["variable types"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/","name":"What is Boolean Variable in Bash? [3 Cases With Examples]","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Feature-image-Bash-boolean-variable.png","datePublished":"2023-08-16T06:50:07+00:00","dateModified":"2024-01-18T11:35:56+00:00","description":"Use the Boolean variable in Bash to create more versatile, responsive, and condition-driven scripts by handling a wide range of scenarios.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Feature-image-Bash-boolean-variable.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Feature-image-Bash-boolean-variable.png","width":400,"height":400,"caption":"Feature image-Bash Boolean variable"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/boolean-variables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxsimply.com\/"},{"@type":"ListItem","position":2,"name":"Bash Scripting Tutorial","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/"},{"@type":"ListItem","position":3,"name":"Bash Variables","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/"},{"@type":"ListItem","position":4,"name":"Types of Variables in Bash","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/variables\/types\/"},{"@type":"ListItem","position":5,"name":"What is Boolean Variable in Bash? [3 Cases With Examples]"}]},{"@type":"WebSite","@id":"https:\/\/linuxsimply.com\/#website","url":"https:\/\/linuxsimply.com\/","name":"LinuxSimply","description":"All About Linux","publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxsimply.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxsimply.com\/#organization","name":"LinuxSimply","url":"https:\/\/linuxsimply.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","width":355,"height":48,"caption":"LinuxSimply"},"image":{"@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/69b717a03a5d9dc48e683aaffe22d33f","name":"Nadiba Rahman","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Nadiba-Rahman-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Nadiba-Rahman-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Nadiba-Rahman-II-96x96.png","caption":"Nadiba Rahman"},"description":"Hello, This is Nadiba Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation with a bachelor\u2019s degree in Electronics &amp; Telecommunication Engineering from Rajshahi University of Engineering &amp; Technology (RUET).I am quite passionate about crafting. I really adore exploring and learning new things which always helps me to think transparently. And this curiosity led me to pursue knowledge about Linux. My goal is to portray Linux-based practical problems and share them with you. Read Full Bio","sameAs":["https:\/\/www.facebook.com\/nadiba.rahman?mibextid=ZbWKwL","https:\/\/www.linkedin.com\/in\/nadiba-rahman-443459171"],"url":"https:\/\/linuxsimply.com\/author\/nadiba\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/16366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/users\/314905"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=16366"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/16366\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/16399"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=16366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=16366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=16366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}