{"id":30276,"date":"2023-12-10T05:58:43","date_gmt":"2023-12-10T05:58:43","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=30276"},"modified":"2024-05-09T11:46:14","modified_gmt":"2024-05-09T11:46:14","slug":"double-square-brackets-in-if-statement-in-bash","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/","title":{"rendered":"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash"},"content":{"rendered":"<p style=\"text-align: justify;\" align=\"left\">The double square brackets [[ ]] within an \u2018if\u2019 statement in Bash introduce extended capabilities for performing conditional tests compared to single square brackets [ ]. You can employ double square brackets [[ ]] in various schemes in Bash such as string comparisons, numeric comparisons, file comparisons, regex matching, validating compound conditionals and pattern matching etc.<\/p>\n<p style=\"text-align: justify;\" align=\"left\">In this article, I will demonstrate <b>6<\/b> different examples of using double square brackets [[ ]] within an \u2018if\u2019 condition in Bash.<\/p>\n<p align=\"left\"><div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Practice-Files_Bash-If-Double-Square-Brackets.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> Practice Files of Double Square Brackets \u2018[[ ]]\u2019 in Bash If Statement<\/span><\/a><\/div>\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' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#What_Are_Double_Square_Brackets_%E2%80%9C_%E2%80%9D_in_Bash\" >What Are Double Square Brackets &#8220;[[ ]]&#8221; in Bash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#6_Examples_of_Using_Double_Square_Brackets_%E2%80%9C_%E2%80%9D_With_%E2%80%9Cif%E2%80%9D_Condition_in_Bash\" >6 Examples of Using Double Square Brackets \u201c[[ ]]\u201d With \u201cif\u201d Condition 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-3\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Example_1_Numeric_Comparison_Test_Using_Double_Brackets\" >Example 1: Numeric Comparison Test Using Double Brackets<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Example_2_String_Comparison_Test_Using_Double_Brackets_in_If_Statement\" >Example 2: String Comparison Test Using Double Brackets in If Statement<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Example_3_Checking_File_Existence_Using_Double_Brackets_in_Bash\" >Example 3: Checking File Existence Using Double Brackets in Bash<\/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\/conditional-statements\/if\/double-brackets\/#Example_4_Matching_Regular_Expression_Regex_in_Bash_Using_Double_Brackets\" >Example 4: Matching Regular Expression (Regex) in Bash Using Double Brackets<\/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\/conditional-statements\/if\/double-brackets\/#Example_5_Verifying_Compound_Conditions_With_Logical_Operators\" >Example 5: Verifying Compound Conditions With Logical Operators<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Example_6_Performing_Globbing_for_Pattern_Matching_in_Bash\" >Example 6: Performing Globbing for Pattern Matching in Bash<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Difference_Between_Single_and_Double_Square_Brackets_in_Bash\" >Difference Between Single and Double Square Brackets in Bash<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#People_Also_Ask\" >People Also Ask<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Why_double_square_brackets_dont_work_in_if_statement_with_grep\" >Why double square brackets don&#8217;t work in if statement with grep?<\/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\/conditional-statements\/if\/double-brackets\/#Are_double_square_brackets_preferable_over_single_square_brackets_in_Bash\" >Are double square brackets [[ ]] preferable over single square brackets [ ] in Bash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Can_I_use_double_brackets_in_any_version_of_Bash\" >Can I use double brackets in any version of Bash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Are_double_brackets_necessary_for_simple_comparisons\" >Are double brackets necessary for simple comparisons?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Can_I_nest_double_brackets_within_%E2%80%98if_statements\" >Can I nest double brackets within &#8216;if&#8217; statements?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#Can_I_use_double_brackets_for_checking_if_a_string_contains_a_specific_substring\" >Can I use double brackets for checking if a string contains a specific substring?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"western\"><span class=\"ez-toc-section\" id=\"What_Are_Double_Square_Brackets_%E2%80%9C_%E2%80%9D_in_Bash\"><\/span>What Are Double Square Brackets &#8220;[[ ]]&#8221; in Bash?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\" align=\"left\">The double square brackets [[ ]] are treated as an extended command in Bash which is a convenient alternative to single square brackets [ ]. This double brackets [[ ]] structure was first introduced in <b>Korn SHell (ksh)<\/b>.<\/p>\n<p style=\"text-align: justify;\" align=\"left\">However, it is now used in Bash for more complex and versatile conditional tests within \u2018if\u2019 statements. These brackets offer improved functionalities in terms of pattern matching, parameter expansion, error handling etc. Using [[ ]] structure helps in preventing word splitting in Bash scripts.<\/p>\n<p align=\"left\">The syntax for using double brackets [[ ]] in &#8216;if&#8217; statements is as follows:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">if [[ condition ]]; then\n#Code to execute if the condition is true\nfi<\/code><\/pre>\n<h2 class=\"western\"><span class=\"ez-toc-section\" id=\"6_Examples_of_Using_Double_Square_Brackets_%E2%80%9C_%E2%80%9D_With_%E2%80%9Cif%E2%80%9D_Condition_in_Bash\"><\/span>6 Examples of Using Double Square Brackets \u201c[[ ]]\u201d With \u201cif\u201d Condition in Bash<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\" align=\"left\">Double square brackets [[ ]] in Bash provide distinct conditional tests and evaluations with additional features. Following are some examples stating how double square brackets [[ ]] can be implemented within the \u2018if\u2019 conditional statement in Bash:<\/p>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Example_1_Numeric_Comparison_Test_Using_Double_Brackets\"><\/span>Example 1: Numeric Comparison Test Using Double Brackets<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">The double square brackets [[ ]] offer a direct way to perform numeric comparison tests in Bash by using several numeric operators such as <strong>-eq<\/strong> (equal), <strong>-ne<\/strong> (not equal), <strong>-lt<\/strong> (less than), <strong>-le<\/strong> (less than or equal), <strong>-gt<\/strong> (greater than) and <strong>-ge<\/strong> (greater than or equal). You can use the syntax <code class=\"\" data-line=\"\">if [[ number1 OPERATOR number2 ]];<\/code> to compare two numeric values with the [[ ]] construct. Let\u2019s see an example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Defining two variables\nnumber1=5\nnumber2=15\n\n#Checking if a number is less than another one\nif [[ $number1 -lt $number2 ]]; then\necho &quot;$number1 is less than $number2&quot;\nfi<\/code><\/pre>\n<p align=\"left\"><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;\" align=\"left\">In the script, <code class=\"\" data-line=\"\">if [[ $num1 -lt $num2 ]];<\/code> checks if the variable <strong>number1<\/strong> is less than the variable <strong>number2<\/strong>. If it satisfies the condition, the script executes a true expression.<\/p>\n<p align=\"left\"><\/div><\/div>\n<p align=\"left\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-30280\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Numeric-comparison-using-double-square-brackets-.png\" alt=\"Numeric comparison using double square brackets '[[ ]]' in Bash 'if' statement\" width=\"700\" height=\"173\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Numeric-comparison-using-double-square-brackets-.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Numeric-comparison-using-double-square-brackets--300x74.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Example_2_String_Comparison_Test_Using_Double_Brackets_in_If_Statement\"><\/span>Example 2: String Comparison Test Using Double Brackets in If Statement<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">The double square brackets [[ ]] in Bash \u2018if\u2019 statement can be used to compare strings with various string comparison operators such as <strong>=<\/strong> (equal), <strong>!=<\/strong> (not equal), <strong>&gt;<\/strong> (greater than), <strong>&lt;<\/strong> (less than), <strong>&gt;=<\/strong> (greater than or equal) and <strong>&lt;=<\/strong> (less than or equal). To accomplish these conditional tasks, use the syntax <code class=\"\" data-line=\"\">if [[ string1 OPERATOR string2 ]];<\/code>. Let\u2019s see how it works:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Defining two variables\nstr1=&quot;Hello&quot;\nstr2=&quot;Linux&quot;\n\n#Checking if a string is not equal to another one\nif [[ $str1 != $str2 ]]; then\necho &quot;Strings are not equal&quot;\nfi<\/code><\/pre>\n<p align=\"left\"><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;\" align=\"left\">Here, <code class=\"\" data-line=\"\">if [[ $str1 != $str2 ]];<\/code> validates whether the two strings <strong>str1<\/strong> and <strong>str2<\/strong> are equal or not. If it returns true, the script prints \u2018Strings are not equal\u2019.<\/p>\n<p align=\"left\"><\/div><\/div>\n<p align=\"left\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-30281\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/String-comparison-using-double-square-brackets-.png\" alt=\"String comparison using double square brackets '[[ ]]' in Bash 'if' statement\" width=\"644\" height=\"148\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/String-comparison-using-double-square-brackets-.png 644w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/String-comparison-using-double-square-brackets--300x69.png 300w\" sizes=\"(max-width: 644px) 100vw, 644px\" \/><\/p>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Example_3_Checking_File_Existence_Using_Double_Brackets_in_Bash\"><\/span>Example 3: Checking File Existence Using Double Brackets in Bash<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">Multiple file and directory test operations can be done using the double square brackets [[ ]] in Bash \u2018if\u2019 conditional statements. To accomplish these tasks, you can use the <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/#E_Bash_File_Test_Operators\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #1155cc;\"><u><b>file test operators<\/b><\/u><\/span><\/a> within conditional statements in Bash. Here\u2019s an example demonstrating how to check file existence by employing <code class=\"\" data-line=\"\">if [[ OPERATOR file_name ]];<\/code> syntax:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Defining a variable\nfile=&quot;tag.sh&quot;\n\n#Checking if the file exists\nif [[ -e $file ]]; then\necho &quot;The file exists.&quot;\nfi<\/code><\/pre>\n<p align=\"left\"><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;\" align=\"left\">Here, <code class=\"\" data-line=\"\">if [[ -e $file ]];<\/code> checks if the assigned file <strong>tag.sh<\/strong> exists or not. If the file exists, the script executes a true expression and displays \u2018The file exists.\u2019.<\/p>\n<p align=\"left\"><\/div><\/div>\n<p align=\"left\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-30282\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/File-existence-check-using-double-square-brackets-.png\" alt=\"File existence check using double square brackets '[[ ]]' in Bash 'if' statement\" width=\"558\" height=\"161\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/File-existence-check-using-double-square-brackets-.png 558w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/File-existence-check-using-double-square-brackets--300x87.png 300w\" sizes=\"(max-width: 558px) 100vw, 558px\" \/><\/p>\n<p align=\"left\">The above image states that the file I have assigned in the script exists in my system.<\/p>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Example_4_Matching_Regular_Expression_Regex_in_Bash_Using_Double_Brackets\"><\/span>Example 4: Matching Regular Expression (Regex) in Bash Using Double Brackets<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">Regular expression (Regex) inside double square brackets [[ ]] in Bash provides flexible pattern matching based on certain criteria. In this case, you can use the <code class=\"\" data-line=\"\">=~<\/code> operator along with double square brackets [[ ]] to perform regular expression matching. Take a look at the following example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Defining a variable\nemail_id=&quot;xyz@gmail.com&quot;\n\n#Checking if the email address matches the pattern\nif [[ $email_id =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}$ ]]; then\necho &quot;A valid email.&quot;\nfi<\/code><\/pre>\n<p align=\"left\"><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;\" align=\"left\">Here, the \u2018if\u2019 conditional statement checks if the variable <code class=\"\" data-line=\"\">email_id<\/code> matches the specified regular expression pattern for a verified email address format. If the email address matches the pattern, it executes a true expression and prints \u2018A valid email.\u2019.<\/p>\n<p align=\"left\"><\/div><\/div>\n<p align=\"left\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-30283\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Matching-regex-pattern-using-double-square-brackets-.png\" alt=\"Matching regular expression (regex) pattern using double square brackets '[[ ]]' in Bash 'if' statement\" width=\"555\" height=\"164\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Matching-regex-pattern-using-double-square-brackets-.png 555w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Matching-regex-pattern-using-double-square-brackets--300x89.png 300w\" sizes=\"(max-width: 555px) 100vw, 555px\" \/><\/p>\n<p style=\"text-align: justify;\" align=\"left\">You can see from the image that the assigned email_id validates the basic format of an email address successfully.<\/p>\n<p style=\"text-align: justify;\" align=\"left\"><div class=\"su-note\"  style=\"border-color:#cedfe2;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#E8F9FC;border-color:#ffffff;color:#333333;\"><b>Note<\/b>: This regex pattern may not support all common email formats and needs to be changed according to the requirements.<\/div><\/div>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Example_5_Verifying_Compound_Conditions_With_Logical_Operators\"><\/span>Example 5: Verifying Compound Conditions With Logical Operators<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">The logical operators <code class=\"\" data-line=\"\">&amp;&amp;<\/code> (AND) and <code class=\"\" data-line=\"\">||<\/code> (OR) and multiple conditions can be utilized together within double square brackets [[ ]] to perform more complex conditional evaluations. Let\u2019s see an example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Defining a variable\nnumber=20\n\n#Checking compound conditions with logical operators\nif [[ ($number -lt 25 &amp;&amp; $number != 30) || $number -gt 40 ]]; then\necho &quot;Satisfies the compound conditions.&quot;\nfi<\/code><\/pre>\n<p align=\"left\"><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;\" align=\"left\">In this script, the compound if statement validates whether the value of the number is less than <strong>25<\/strong> and not equal to <strong>30<\/strong> or greater than <strong>40<\/strong>. If all the conditions are met, it returns a true expression.<\/p>\n<p align=\"left\"><\/div><\/div>\n<p align=\"left\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-30284\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Verifying-compound-conditions-with-logical-operators-using-.png\" alt=\"Verifying compound conditions with logical operators using '[[ ]]' in Bash\" width=\"700\" height=\"161\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Verifying-compound-conditions-with-logical-operators-using-.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Verifying-compound-conditions-with-logical-operators-using--300x69.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p align=\"left\">This image indicates compound conditional validation using logical operators within [[ ]].<\/p>\n<p align=\"left\"><div class=\"su-note\"  style=\"border-color:#cedfe2;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#E8F9FC;border-color:#ffffff;color:#333333;\"><strong>Note<\/strong>: If you want to replace <code class=\"\" data-line=\"\">&amp;&amp;<\/code> and <code class=\"\" data-line=\"\">||<\/code> with the test operators <code class=\"\" data-line=\"\">-a<\/code> (logical AND) and <code class=\"\" data-line=\"\">-o<\/code> (logical OR), you must enclose them within single square brackets <code class=\"\" data-line=\"\">[ ]<\/code>.<\/div><\/div>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Example_6_Performing_Globbing_for_Pattern_Matching_in_Bash\"><\/span>Example 6: Performing Globbing for Pattern Matching in Bash<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">In Bash scripting, the term <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/expansion\/glob-expansion\/\" target=\"_blank\" rel=\"noopener\"><strong>globbing<\/strong><\/a>\u00a0refers to the process of using <b>wildcard characters<\/b> for matching and manipulating filenames or paths effectively based on patterns. Some widely used wildcard characters for globbing in Bash are <code class=\"\" data-line=\"\">*<\/code> (<b>Asterisk<\/b>), <code class=\"\" data-line=\"\">?<\/code> (<b>Question Mark<\/b>) and <code class=\"\" data-line=\"\">[ ]<\/code> (<b>Square Brackets<\/b>) etc.<\/p>\n<p style=\"text-align: justify;\" align=\"left\">You can match filenames with a specific prefix, extension, list files, check specific substring etc by performing globbing within double square brackets [[ ]] in Bash. Following is an example demonstrating how globbing works within [[ ]]:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Defining a variable\nprefix_part=&quot;hash&quot;\n\nfor file in *; do\nif [[ $file == &quot;$prefix_part&quot;* ]]; then\necho &quot;Valid file $file with &#039;$prefix_part prefix.&quot;\nfi\ndone<\/code><\/pre>\n<p align=\"left\"><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;\" align=\"left\">The script searches all files in the current working directory and verifies all the filenames (using globbing pattern <b>*<\/b>) starting with the given prefix. Every time a file matches the condition, it returns a true expression.<\/p>\n<p align=\"left\"><\/div><\/div>\n<p align=\"left\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-30285\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Matching-files-with-a-prefix-by-performing-globbing-with-.png\" alt=\"Performing globbing for pattern matching in Bash\" width=\"700\" height=\"188\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Matching-files-with-a-prefix-by-performing-globbing-with-.png 700w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Matching-files-with-a-prefix-by-performing-globbing-with--300x81.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p style=\"text-align: justify;\" align=\"left\">In this image, you can see that all the files in my current working directory have been identified that start with a prefix <strong>hash<\/strong>.<\/p>\n<h2 class=\"western\"><span class=\"ez-toc-section\" id=\"Difference_Between_Single_and_Double_Square_Brackets_in_Bash\"><\/span>Difference Between Single and Double Square Brackets in Bash<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\" align=\"left\">In Bash scripting, both single square brackets [ ] and double square brackets [[ ]] are used to perform test operations in different conditional statements and loops. However, there are some possible differences between them in terms of functional features. Following is a tabular representation of the key differences between single and double square brackets in Bash:<\/p>\n<p align=\"left\"><div class=\"su-table su-table-responsive su-table-alternate su-table-fixed\">\n<table style=\"width: 100%\" width=\"100%\" cellspacing=\"0\" cellpadding=\"7\">\n<tbody>\n<tr valign=\"top\">\n<th width=\"167\">\n<p align=\"center\"><b>Functions<\/b><\/p>\n<\/th>\n<th width=\"189\">\n<p align=\"center\"><b>Single Square Brackets [ ]<\/b><\/p>\n<\/th>\n<th width=\"200\">\n<p align=\"center\"><b>Double Square Brackets [[ ]]<\/b><\/p>\n<\/th>\n<\/tr>\n<tr valign=\"top\">\n<td style=\"width: 167px;vertical-align: middle\" width=\"167\">\n<p align=\"left\">Basic Feature<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"189\">\n<p align=\"left\">\u2018[ ]\u2019 is a built-in command in Bash.<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"200\">\n<p align=\"left\">\u2018[[ ]]\u2019 is an extended Bash command that is the enhanced version of \u2018[ ]\u2019.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td style=\"vertical-align: middle\" width=\"167\">\n<p align=\"left\">Logical Operators<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"189\">\n<p align=\"left\">Supports not only &amp;&amp; and || logical operators but also -a and -o operators.<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"200\">\n<p align=\"left\">Supports only &amp;&amp; and || logical operators.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td style=\"vertical-align: middle\" width=\"167\">\n<p align=\"left\">Regex Matching<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"189\">\n<p align=\"left\">Does not support regex matching.<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"200\">\n<p align=\"left\">Uses =~ operator for regex matching.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td style=\"vertical-align: middle\" width=\"167\">\n<p align=\"left\">Quoting during String Handling<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"189\">\n<p align=\"left\">Requires explicit quoting.<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"200\">\n<p align=\"left\">No explicit quoting.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td style=\"vertical-align: middle\" width=\"167\">\n<p align=\"left\">Parentheses \u2018( )\u2019 for Grouping Expressions<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"189\">\n<p align=\"left\">Use an <b>escape character<\/b> before \u2018(\u2018 and \u2018)\u2019 and a space after \u2018(\u2018 and \u2018)\u2019.<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"200\">\n<p align=\"left\">Use the parentheses directly without any escape character.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td style=\"vertical-align: middle\" width=\"167\">\n<p align=\"left\">Pattern Matching<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"189\">\n<p align=\"left\">Supports limited pattern matching.<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"200\">\n<p align=\"left\">Supports more versatile pattern matching.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td style=\"vertical-align: middle\" width=\"167\">\n<p align=\"left\">Supported Bash Versions<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"189\">\n<p align=\"left\">Compatible for all versions.<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"200\">\n<p align=\"left\">Does not work in older versions.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td style=\"vertical-align: middle\" width=\"167\">\n<p align=\"left\">Word Splitting<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"189\">\n<p align=\"left\">Supports word splitting for unquoted variables.<\/p>\n<\/td>\n<td style=\"vertical-align: middle\" width=\"200\">\n<p align=\"left\">Does not support word splitting.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p align=\"left\"><\/div>\n<h2 class=\"western\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\" align=\"left\">To sum up, using double square brackets [[ ]] within &#8216;if&#8217; statements in Bash enables users to evaluate more advanced conditional tests and create more versatile Bash scripts.<\/p>\n<h2 class=\"western\"><span class=\"ez-toc-section\" id=\"People_Also_Ask\"><\/span>People Also Ask<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Why_double_square_brackets_dont_work_in_if_statement_with_grep\"><\/span>Why double square brackets don&#8217;t work in if statement with grep?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">Double square brackets don&#8217;t directly work with the &#8216;grep&#8217; command in an \u2018if\u2019 statement because it is an external command in Bash. However, you can use the \u2018grep\u2019 command in the \u2018if\u2019 statement by using the test command or equivalent test operator \u2018[ ]\u2019. For example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nstring=&quot;Hello, Linux!&quot;\n\nif [ &quot;$(echo &quot;$string&quot; | grep &quot;Linux&quot;)&quot; ]; then\necho &quot;&#039;Linux&#039; exists in the string.&quot;\nfi<\/code><\/pre>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Are_double_square_brackets_preferable_over_single_square_brackets_in_Bash\"><\/span>Are double square brackets [[ ]] preferable over single square brackets [ ] in Bash?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">In Bash, double square brackets \u2018[[ ]]\u2019 are preferable to use in some cases over single square brackets \u2018[ ]\u2019 due to their improved functionality, ease of use, code readability, and better error handling features.<\/p>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Can_I_use_double_brackets_in_any_version_of_Bash\"><\/span>Can I use double brackets in any version of Bash?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\">You can use double square brackets [[ ]] in most recent versions of Bash. However, note that \u2018[[ ]]\u2019 is not supported in older or limited versions of Bash.<\/p>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Are_double_brackets_necessary_for_simple_comparisons\"><\/span>Are double brackets necessary for simple comparisons?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\"><b>No<\/b>, double brackets are not necessary to use for simple comparisons in Bash, rather you can use single square brackets [ ] or the \u2018test\u2019 command.<\/p>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Can_I_nest_double_brackets_within_%E2%80%98if_statements\"><\/span>Can I nest double brackets within &#8216;if&#8217; statements?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\"><b>Yes<\/b>, you can nest double brackets within &#8216;if&#8217; statements to evaluate more complex conditional expressions in Bash. For instance:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Defining a variable\nnumber=30\n\nif [[ $number -lt 50 ]]; then\nif [[ $number -gt 10 ]]; then\necho &quot;The number $number is between 10 and 50.&quot;\nfi\nfi<\/code><\/pre>\n<h3 class=\"western\"><span class=\"ez-toc-section\" id=\"Can_I_use_double_brackets_for_checking_if_a_string_contains_a_specific_substring\"><\/span>Can I use double brackets for checking if a string contains a specific substring?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\" align=\"left\"><b>Yes<\/b>, you can use double brackets to check if a string contains a specific substring using the syntax <code class=\"\" data-line=\"\">[[ $string == *substring* ]]<\/code>. For example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nstring=&quot;Hello, welcome to Linuxsimply!&quot;\n\nif [[ $string == *&quot;welcome to&quot;* ]]; then\necho &quot;The string contains &#039;welcome to&#039;.&quot;\nfi<\/code><\/pre>\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\/conditional-statements\/if\/if-options\/\" target=\"_blank\" rel=\"noopener\">Mastering 10 Essential Options of If Statement in Bash<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/if-true-false\/\" target=\"_blank\" rel=\"noopener\">How to Check a Boolean If True or False in Bash [Easy Guide]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/if-test\/\" target=\"_blank\" rel=\"noopener\">Bash Test Operations in \u2018If\u2019 Statement<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/if-empty-or-not\/\" target=\"_blank\" rel=\"noopener\">Check If a Variable is Empty\/Null or Not in Bash [5 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/set-variable-if-not\/\" target=\"_blank\" rel=\"noopener\">Check If a Variable is Set or Not in Bash [4 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/environment-variable-exists\/\" target=\"_blank\" rel=\"noopener\">Check If Environment Variable Exists in Bash [6 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/modulo-if\/\" target=\"_blank\" rel=\"noopener\">Bash Modulo Operations in &#8220;If&#8221; Statement [4 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/or-and-not-in-if\/\" target=\"_blank\" rel=\"noopener\">How to Use &#8220;OR&#8221;, &#8220;AND&#8221;, &#8220;NOT&#8221; in Bash If Statement [7 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/multiple-if-conditions\/\" target=\"_blank\" rel=\"noopener\">Evaluate Multiple Conditions in Bash \u201cIf\u201d Statement [2 Ways]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/check-if-file-exists\/\" target=\"_blank\" rel=\"noopener\">6 Ways to Check If a File Exists or Not in Bash<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/check-if-file-is-empty\/\" target=\"_blank\" rel=\"noopener\">How to Check If a File is Empty in Bash [6 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/check-if-directory-exists\/\" target=\"_blank\" rel=\"noopener\">7 Ways to Check If Directory Exists or Not in Bash<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/negate-if\/\" target=\"_blank\" rel=\"noopener\">Negate an &#8220;If&#8221; Condition in Bash [4 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/if-command-fails\/\" target=\"_blank\" rel=\"noopener\">Check If Bash Command Fail or Succeed [Exit If Fail]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/if-one-line\/\" target=\"_blank\" rel=\"noopener\">How to Write If Statement in One Line? [2 Easy Ways]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/if-loop\/\" target=\"_blank\" rel=\"noopener\">Different Loops with If Statements in Bash [5 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/flags\/\" target=\"_blank\" rel=\"noopener\">How to Use Flags in Bash If Condition? [With Example]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/compare-dates\/\" target=\"_blank\" rel=\"noopener\">Learn to Compare Dates in Bash [4 Examples]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<p><strong>&lt;&lt; Go Back to <span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;If Statement in Bash&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1074113,&quot;3&quot;:{&quot;1&quot;:0},&quot;9&quot;:1,&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;16&quot;:12,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/\" target=\"_blank\" rel=\"noopener\">If Statement in Bash<\/a><\/span> | <span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Conditional Statements&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1074113,&quot;3&quot;:{&quot;1&quot;:0},&quot;9&quot;:1,&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;16&quot;:12,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/\" target=\"_blank\" rel=\"noopener\">Bash Conditional Statements<\/a><\/span> | <span data-sheets-root=\"1\" data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Scripting Tutorial&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1074113,&quot;3&quot;:{&quot;1&quot;:0},&quot;9&quot;:1,&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;16&quot;:12,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a><\/span><\/strong><\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"Are double square brackets [[ ]] preferable over single square brackets [ ] in Bash?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"In Bash, double square brackets \u2018[[ ]]\u2019 are preferable to use in some cases over single square brackets \u2018[ ]\u2019 due to their improved functionality, ease of use, code readability, and better error handling features.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Can I use double brackets in any version of Bash?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"You can use double square brackets [[ ]] in most recent versions of Bash. However, note that \u2018[[ ]]\u2019 is not supported in older or limited versions of Bash.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Are double brackets necessary for simple comparisons?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"No, double brackets are not necessary to use for simple comparisons in Bash, rather you can use single square brackets [ ] or the \u2018test\u2019 command.\"\n    }\n  }]\n}\n<\/script><\/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;30276&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;Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash&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>The double square brackets [[ ]] within an \u2018if\u2019 statement in Bash introduce extended capabilities for performing conditional tests compared &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#more-30276\" aria-label=\"Read more about Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash\">Read more<\/a><\/p>\n","protected":false},"author":314905,"featured_media":30278,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[166],"class_list":["post-30276","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-if-statement","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>Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash - LinuxSimply<\/title>\n<meta name=\"description\" content=\"Practice different test operations using double square brackets &#039;[[ ]]&#039; within the &#039;if&#039; statement in Bash scripting.\" \/>\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\/conditional-statements\/if\/double-brackets\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash - LinuxSimply\" \/>\n<meta property=\"og:description\" content=\"Practice different test operations using double square brackets &#039;[[ ]]&#039; within the &#039;if&#039; statement in Bash scripting.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/\" \/>\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-12-10T05:58:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-09T11:46:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.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=\"9 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\\\/conditional-statements\\\/if\\\/double-brackets\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/\"},\"author\":{\"name\":\"Nadiba Rahman\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/69b717a03a5d9dc48e683aaffe22d33f\"},\"headline\":\"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash\",\"datePublished\":\"2023-12-10T05:58:43+00:00\",\"dateModified\":\"2024-05-09T11:46:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/\"},\"wordCount\":1667,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png\",\"keywords\":[\"if statement\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/\",\"name\":\"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash - LinuxSimply\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png\",\"datePublished\":\"2023-12-10T05:58:43+00:00\",\"dateModified\":\"2024-05-09T11:46:14+00:00\",\"description\":\"Practice different test operations using double square brackets '[[ ]]' within the 'if' statement in Bash scripting.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png\",\"width\":400,\"height\":400,\"caption\":\"Feature image-Double Square Brackets in Bash If Statement\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/double-brackets\\\/#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 Conditional Statements\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"If Statement in Bash\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/conditional-statements\\\/if\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash\"}]},{\"@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":"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash - LinuxSimply","description":"Practice different test operations using double square brackets '[[ ]]' within the 'if' statement in Bash scripting.","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\/conditional-statements\/if\/double-brackets\/","og_locale":"en_US","og_type":"article","og_title":"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash - LinuxSimply","og_description":"Practice different test operations using double square brackets '[[ ]]' within the 'if' statement in Bash scripting.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/nadiba.rahman?mibextid=ZbWKwL","article_published_time":"2023-12-10T05:58:43+00:00","article_modified_time":"2024-05-09T11:46:14+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png","type":"image\/png"}],"author":"Nadiba Rahman","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nadiba Rahman","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/"},"author":{"name":"Nadiba Rahman","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/69b717a03a5d9dc48e683aaffe22d33f"},"headline":"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash","datePublished":"2023-12-10T05:58:43+00:00","dateModified":"2024-05-09T11:46:14+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/"},"wordCount":1667,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png","keywords":["if statement"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/","name":"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash - LinuxSimply","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png","datePublished":"2023-12-10T05:58:43+00:00","dateModified":"2024-05-09T11:46:14+00:00","description":"Practice different test operations using double square brackets '[[ ]]' within the 'if' statement in Bash scripting.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/12\/Feature-image-Double-Square-Brackets-in-Bash-If-Statement.png","width":400,"height":400,"caption":"Feature image-Double Square Brackets in Bash If Statement"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/double-brackets\/#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 Conditional Statements","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/"},{"@type":"ListItem","position":4,"name":"If Statement in Bash","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if\/"},{"@type":"ListItem","position":5,"name":"Using Double Square Brackets \u201c[[ ]]\u201d in If Statement in Bash"}]},{"@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\/30276","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=30276"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/30276\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/30278"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=30276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=30276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=30276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}