{"id":26135,"date":"2023-11-06T08:10:49","date_gmt":"2023-11-06T08:10:49","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=26135"},"modified":"2024-04-02T04:44:51","modified_gmt":"2024-04-02T04:44:51","slug":"bash-comparison-operators","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/","title":{"rendered":"An Overview of Bash Comparison [Conditional] Operators"},"content":{"rendered":"<p style=\"text-align: justify;\">Bash Comparison Operators are fundamental elements in scripting that allow Bash programmers to <strong>compare values<\/strong> and make decisions based on results. These operators enable programmers to establish conditions, control the flow of the bash script, and <strong>create dynamic, responsive programs<\/strong>. Whether anyone compares numerical values, tests strings, or validates user input, Bash Comparison Operators provide the building blocks for intelligent decision-making within Bash Scripts. Here I will give you an overview of Bash comparison operators.<\/p>\n<div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/bash-comparison-operators-scripts.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 to Work with Bash Comparison Operators<\/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\/operator\/comparison-operators\/#What_are_Comparison_Conditional_Operators_in_Bash\" >What are Comparison [Conditional] Operators 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\/operator\/comparison-operators\/#List_of_Bash_Operators_for_the_Comparison_of_Strings_Lexicographic_Comparison\" >List of Bash Operators for the Comparison of Strings [Lexicographic Comparison]<\/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\/operator\/comparison-operators\/#Example_1_Comparing_Two_Bash_Strings_Using_Comparison_Operator\" >Example 1: Comparing Two Bash Strings Using Comparison Operator<\/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\/operator\/comparison-operators\/#List_of_Bash_Operators_for_the_Comparison_of_Integer_Numbers\" >List of Bash Operators for the Comparison of Integer Numbers<\/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\/operator\/comparison-operators\/#Example_2_Comparing_Two_Integer_Numbers_Using_Comparison_Operator\" >Example 2: Comparing Two Integer Numbers Using Comparison Operator<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#Why_Bash_Comparison_Operators_are_Necessary\" >Why Bash Comparison Operators are Necessary?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#Conclusion\" >Conclusion<\/a><\/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\/operator\/comparison-operators\/#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-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#What_is_greater_than_comparison_in_Bash\" >What is greater than comparison in Bash?<\/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\/operator\/comparison-operators\/#What_do_comparison_operators_return\" >What do comparison operators return?<\/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\/operator\/comparison-operators\/#What_is_the_function_of_the_comparison_operator\" >What is the function of the comparison operator?<\/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\/operator\/comparison-operators\/#What_are_the_operands_of_comparison_operators\" >What are the operands of comparison operators?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"What_are_Comparison_Conditional_Operators_in_Bash\"><\/span>What are Comparison [Conditional] Operators in Bash?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Comparison operators also known as Conditional operators in Bash are used to <strong>evaluate conditions<\/strong> and make script decisions. These operators help determine whether a certain expression or comparison is true or false, allowing the script to take different paths based on the result.<\/p>\n<p>Based on usage comparison operators are mainly of two types in Bash. These are:<\/p>\n<ol>\n<li>Bash comparison operators for comparing strings.<br \/>\n<code class=\"\" data-line=\"\">\u201c$string1\u201d != \u201c$string2\u201d<\/code>Here the <code class=\"\" data-line=\"\">!=<\/code> is the \u201cis not equal to\u201d comparison operator used for comparing strings.<code class=\"\" data-line=\"\">\u201c$string1\u201d &gt; \u201c$string2\u201d<\/code>Here the <code class=\"\" data-line=\"\">&gt;<\/code> is the \u201cgreater than\u201d comparison operator used for comparing strings.<\/li>\n<li>\u00a0Bash comparison operators for comparing numbers.<br \/>\n<code class=\"\" data-line=\"\">&quot;$number1&quot; -gt &quot;$number2&quot;<\/code>Here <code class=\"\" data-line=\"\">-gt<\/code> is the \u201cgreater than\u201d comparison operator used for comparing numbers.<code class=\"\" data-line=\"\">\u201c$number1&quot; -eq &quot;$number2\u201d<\/code>Here <code class=\"\" data-line=\"\">-eq<\/code> is the \u201cis equal to\u201d comparison operator used for comparing numbers.<\/li>\n<\/ol>\n<p>Let&#8217;s obverse a sample code involving comparison operators:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">if [[ $x -eq $y ]]\nthen\necho &quot;x and y are equal!&quot;\nelse\necho &quot;x and y are not equal!&quot;\nfi<\/code><\/pre>\n<p>Here the <code class=\"\" data-line=\"\">-eq<\/code> is the \u201cis equal to\u201d comparison operator used for comparing the x and the y numbers.<\/p>\n<p>There are also other comparison operators. In the subsequent section, I will discuss those operators.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"List_of_Bash_Operators_for_the_Comparison_of_Strings_Lexicographic_Comparison\"><\/span>List of Bash Operators for the Comparison of Strings [Lexicographic Comparison]<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"su-table su-table-responsive su-table-alternate su-table-fixed\">\n<table class=\" aligncenter\" style=\"width: 105.723%\" width=\"100%\">\n<tbody>\n<tr>\n<th style=\"width: 10.7438%\" width=\"208\"><strong>Operator<\/strong><\/th>\n<th style=\"width: 25.3687%\" width=\"208\"><strong>Meaning<\/strong><\/th>\n<th style=\"width: 33.4657%\" width=\"208\"><strong>Syntax<\/strong><\/th>\n<\/tr>\n<tr>\n<td style=\"width: 10.7438%;text-align: center;vertical-align: middle\" width=\"208\">=<\/td>\n<td style=\"width: 25.3687%\" width=\"208\">\n<ul>\n<li>is equal to<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.4657%\" width=\"208\">\n<ul>\n<li>if [ &#8220;$a&#8221; = &#8220;$b&#8221; ]<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 10.7438%;text-align: center;vertical-align: middle\" width=\"208\">==<\/td>\n<td style=\"width: 25.3687%\" width=\"208\">\n<ul>\n<li>is equal to<\/li>\n<li>The == comparison operator behaves differently within a double-brackets test than within single brackets.<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.4657%\" width=\"208\">\n<ul>\n<li>[[ $a == z* ]] True if $a starts with a &#8220;z&#8221; (pattern matching).<\/li>\n<li>[[ $a == &#8220;z*&#8221; ]] True if $a is equal to z* (literal matching).<\/li>\n<li>[ $a == z* ] File globbing and word splitting take place.<\/li>\n<li>[ &#8220;$a&#8221; == &#8220;z*&#8221; ] True if $a is equal to z* (literal matching).<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 10.7438%;text-align: center;vertical-align: middle\" width=\"208\">!=<\/td>\n<td style=\"width: 25.3687%\" width=\"208\">\n<ul>\n<li>is not equal to<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.4657%\" width=\"208\">\n<ul>\n<li>if [ &#8220;$a&#8221; != &#8220;$b&#8221; ]<\/li>\n<li>This operator uses pattern matching within a [[ &#8230; ]] construct.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 10.7438%;text-align: center;vertical-align: middle\" width=\"208\">&lt;<\/td>\n<td style=\"width: 25.3687%\" width=\"208\">\n<ul>\n<li>is less than, in ASCII alphabetical order.<\/li>\n<li>The &lt; needs to be escaped within a [ ] construct.<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.4657%\" width=\"208\">\n<ul>\n<li>if [[ &#8220;$a&#8221; &lt; &#8220;$b&#8221; ]]<\/li>\n<li>if [ &#8220;$a&#8221; \\&lt; &#8220;$b&#8221; ]<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 10.7438%;text-align: center;vertical-align: middle\" width=\"208\">&gt;<\/td>\n<td style=\"width: 25.3687%\" width=\"208\">\n<ul>\n<li>is greater than, in ASCII alphabetical order.<\/li>\n<li>The &gt; needs to be escaped within a [ ] construct.<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.4657%;text-align: left;vertical-align: middle\" width=\"208\">\n<ul>\n<li>if [[ &#8220;$a&#8221; &gt; &#8220;$b&#8221; ]]<\/li>\n<li>if [ &#8220;$a&#8221; \\&gt; &#8220;$b&#8221; ]<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 10.7438%;text-align: center;vertical-align: middle\" width=\"208\">-z<\/td>\n<td style=\"width: 25.3687%\" width=\"208\">\n<ul>\n<li>string is null<\/li>\n<li>It has zero length<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.4657%\" width=\"208\">\n<ul>\n<li>if [ -z &#8220;$s&#8221; ]<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 10.7438%;text-align: center;vertical-align: middle\" width=\"208\">-n<\/td>\n<td style=\"width: 25.3687%\" width=\"208\">\n<ul>\n<li>the string is not null.<\/li>\n<\/ul>\n<\/td>\n<td style=\"width: 33.4657%\" width=\"208\">\n<ul>\n<li>if [ -n &#8220;$s&#8221; ]<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3><span class=\"ez-toc-section\" id=\"Example_1_Comparing_Two_Bash_Strings_Using_Comparison_Operator\"><\/span>Example 1: Comparing Two Bash Strings Using Comparison Operator<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The <code class=\"\" data-line=\"\">==<\/code> comparison operator is used to compare two strings whether they are equal or not.<\/p>\n<p>To compare two strings using the == comparison operator follow the syntax: <code class=\"\" data-line=\"\">&quot;$string1&quot; == &quot;$string2&quot;<\/code>. Here is an example.<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#defining string1 and string2\nstring1=&quot;Linux&quot;\nstring2=&quot;Simply&quot;\n\n#comparing string1 and string2 and print a text according to comparison result\nif [[\u00a0 &quot;$string1&quot; == &quot;$string2&quot; ]]; then\necho &quot;The strings are equal.&quot;\nelse\necho &quot;The strings are different.&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>Here, the <code class=\"\" data-line=\"\">&quot;$string1&quot; == &quot;$string2&quot;<\/code> command will compare if <strong>string1<\/strong> is equal to <strong>string2<\/strong>. If the comparison result is true, it will print \u201cThe strings are equal\u201d. If the comparison result is false, it will print \u201cThe strings are different\u201d on the terminal.<\/p>\n<\/div><\/div>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-26159 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/1.-string-comparison.png\" alt=\"The bash script has checked the equality of string1 and string2 and found that they are not equal.\" width=\"617\" height=\"217\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/1.-string-comparison.png 617w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/1.-string-comparison-300x106.png 300w\" sizes=\"(max-width: 617px) 100vw, 617px\" \/>The Bash script compared the two strings, <strong>string1,<\/strong> and <strong>string2,<\/strong> and found that the strings are different.<\/p>\n<p>Read this article to learn more: <strong><a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if-else\/compare-strings\/\" target=\"_blank\" rel=\"noopener\">How to Compare Strings in Bash With If Statement [6 Methods]<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"List_of_Bash_Operators_for_the_Comparison_of_Integer_Numbers\"><\/span>List of Bash Operators for the Comparison of Integer Numbers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"su-table su-table-responsive su-table-alternate su-table-fixed\">\n<table width=\"624\">\n<tbody>\n<tr>\n<th width=\"208\"><strong>Operator<\/strong><\/th>\n<th width=\"208\"><strong>Meaning<\/strong><\/th>\n<th width=\"208\"><strong>Syntax<\/strong><\/th>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">-eq<\/td>\n<td width=\"208\">is equal to<\/td>\n<td width=\"208\">if [ &#8220;$a&#8221; -eq &#8220;$b&#8221; ]<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">-ne<\/td>\n<td width=\"208\">is not equal to<\/td>\n<td width=\"208\">if [ &#8220;$a&#8221; -ne &#8220;$b&#8221; ]<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">-gt<\/td>\n<td width=\"208\">is greater than<\/td>\n<td width=\"208\">if [ &#8220;$a&#8221; -gt &#8220;$b&#8221; ]<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">-ge<\/td>\n<td width=\"208\">is greater than or equal to<\/td>\n<td width=\"208\">if [ &#8220;$a&#8221; -ge &#8220;$b&#8221; ]<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">-lt<\/td>\n<td width=\"208\">is less than<\/td>\n<td width=\"208\">if [ &#8220;$a&#8221; -lt &#8220;$b&#8221; ]<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">-le<\/td>\n<td width=\"208\">is less than or equal to<\/td>\n<td width=\"208\">if [ &#8220;$a&#8221; -le &#8220;$b&#8221; ]<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">&lt;<\/td>\n<td width=\"208\">is less than<\/td>\n<td width=\"208\">if ((&#8220;$a&#8221; &lt; &#8220;$b&#8221;))<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">&lt;=<\/td>\n<td width=\"208\">is less than or equal to<\/td>\n<td width=\"208\">if ((&#8220;$a&#8221; &lt;= &#8220;$b&#8221;))<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">&gt;<\/td>\n<td width=\"208\">is greater than<\/td>\n<td width=\"208\">if ((&#8220;$a&#8221; &gt; &#8220;$b&#8221;))<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;vertical-align: middle\" width=\"208\">&gt;=<\/td>\n<td width=\"208\">is greater than or equal to<\/td>\n<td width=\"208\">if ((&#8220;$a&#8221; &gt;= &#8220;$b&#8221;))<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3><span class=\"ez-toc-section\" id=\"Example_2_Comparing_Two_Integer_Numbers_Using_Comparison_Operator\"><\/span>Example 2: Comparing Two Integer Numbers Using Comparison Operator<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The <code class=\"\" data-line=\"\">-eq<\/code> comparison operator is a basic approach to comparing two integer numbers whether they are equal or not.<\/p>\n<p style=\"text-align: justify;\">To compare two integer numbers using the <code class=\"\" data-line=\"\">-eq<\/code> comparison operator, you can use the syntax: <code class=\"\" data-line=\"\">&quot;$number1&quot; -eq &quot;$number2&quot;<\/code>. Here is how:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n# Script for equal to numeric comparison\nnumber1=2\nnumber2=2\n\nif [[ $number1 -eq $number2 ]]\nthen\necho &quot;number1 and number2 are equal!&quot;\nelse\necho &quot;number1 and number2 are not equal!&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>Here the <code class=\"\" data-line=\"\">$number1 -eq $number2<\/code> has compared whether variable number1 is equal to variable number2 and if the statement is true, &#8220;number1 and number2 are equal&#8221; text will be printed and if the comparison result is false then the text &#8220;number1 and number2 are not equal!&#8221; will be printed on the terminal.<\/p>\n<\/div><\/div>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"aligncenter wp-image-26160 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/2.-number-comparison.png\" alt=\"The Bash script has checked the equality of number1 and number2 and found that they are equal.\" width=\"590\" height=\"220\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/2.-number-comparison.png 590w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/2.-number-comparison-300x112.png 300w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/>The Bash script compared the two numbers <strong>number1,<\/strong> and <strong>number2,<\/strong> and found that the number1 and number2 are equal.<\/p>\n<p>Read this article to learn more: <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/conditional-statements\/if-else\/compare-numbers\/\" target=\"_blank\" rel=\"noopener\"><strong>How to Compare Numbers in Bash With If Statement [2 Methods]<\/strong><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Why_Bash_Comparison_Operators_are_Necessary\"><\/span>Why Bash Comparison Operators are Necessary?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Bash comparison operators are necessary for:<\/p>\n<ol>\n<li>Enabling execution based on conditions.<\/li>\n<li>Making choices within scripts.<\/li>\n<li>Controlling loop execution based on conditions.<\/li>\n<li>Testing variable values for specific criteria.<\/li>\n<li>Validating command success to prevent issues.<\/li>\n<li>Ensuring user input meets specified criteria.<\/li>\n<li>Tasks like substring checks and string comparisons.<\/li>\n<\/ol>\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;\">Bash comparison operators are one of the vital parts of Bash script. It facilitates the programmers to accomplish the comparison task and make the necessary decision from the result. In this article, I have tried to give you an overview of <strong>bash comparison operators<\/strong> and I believe after going through this article, you are competent enough to use this feature on your Bash scripting activities.<\/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<h3><span class=\"ez-toc-section\" id=\"What_is_greater_than_comparison_in_Bash\"><\/span>What is greater than comparison in Bash?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Greater than comparison in Bash is used to test whether one value is greater than another. The <code class=\"\" data-line=\"\">-gt<\/code> is the operator for greater than comparison in Bash. It is an acronym for <strong>greater than.<\/strong> This <code class=\"\" data-line=\"\">-gt<\/code> operator allows programmers to compare two numeric values and returns a true (0) or false (1) result based on the comparison result.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_do_comparison_operators_return\"><\/span>What do comparison operators return?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Comparison operators return 0 or 1 according to the comparison result. You can compare numbers or strings with comparison operators. Expressions that use comparison operators do not return a number value as do arithmetic expressions. Comparison expressions return 1 the comparison result is true or\u00a0 0, in case of false.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_the_function_of_the_comparison_operator\"><\/span>What is the function of the comparison operator?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The function of the comparison operator is to compare bash variables including numbers and strings and decide whether they are equal, not equal, which one is greater or which one is smaller, etc.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_are_the_operands_of_comparison_operators\"><\/span>What are the operands of comparison operators?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The operands of comparison operators are the left and right components of the operators. You can compare the equality, inequality, or relative values of two operands of the same type based on using a relevant comparison operator. For example, <code class=\"\" data-line=\"\">\u201c$string1\u201d != \u201c$string2\u201d<\/code> compares if string1 and string2 are not equal.<\/p>\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\/operator\/arithmetic-operators\/\" target=\"_blank\" rel=\"noopener\">Arithmetic Operators in Bash<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/logical-operators\/\" target=\"_blank\" rel=\"noopener\">Bash Logical Operators<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/unary-operators\/\" target=\"_blank\" rel=\"noopener\">Unary Operators in Bash<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/ternary-operator\/\" target=\"_blank\" rel=\"noopener\">Usage of Ternary Operator in Bash [with 2 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/bitwise-operators\/\" target=\"_blank\" rel=\"noopener\">Bitwise Operators in Bash Scripting<\/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;Bash Operator&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\/operator\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/\" target=\"_blank\" rel=\"noopener\">Bash Operator<\/a><\/span> | <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a> <\/strong><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"What is greater than comparison in Bash?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Greater than comparison in Bash is used to test whether one value is greater than another. The -gt is the operator for greater than comparison in Bash. It is an acronym for greater than. This -gt operator allows programmers to compare two numeric values and returns a true (0) or false (1) result based on the comparison result.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What do comparison operators return?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Comparison operators return 0 or 1 according to the comparison result. You can compare numbers or strings with comparison operators. Expressions that use comparison operators do not return a number value as do arithmetic expressions. Comparison expressions return 1 the the comparison result is true or  0, in case of false.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is the function of the comparison operator?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"The function of the comparison operator is to compare bash variables including numbers and strings and decide whether they are equal, not equal, which one is greater or which one is smaller, etc.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What are the operands of comparison operators?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"The operands of comparison operators are the left and right components of the operators. You can compare the equality, inequality, or relative values of two operands of the same type based on using a relevant comparison operator. For example, \u201c$string1\u201d != \u201c$string2\u201d compares if string1 and string2 are not equal.\"\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;26135&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;An Overview of Bash Comparison [Conditional] Operators&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>Bash Comparison Operators are fundamental elements in scripting that allow Bash programmers to compare values and make decisions based on &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"An Overview of Bash Comparison [Conditional] Operators\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#more-26135\" aria-label=\"Read more about An Overview of Bash Comparison [Conditional] Operators\">Read more<\/a><\/p>\n","protected":false},"author":314894,"featured_media":26161,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[169],"class_list":["post-26135","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-bash-operator","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>An Overview of Bash Comparison [Conditional] Operators - LinuxSimply<\/title>\n<meta name=\"description\" content=\"Bash comparison operators help programmers to compare string and number and take necessary result from the comparison result.\" \/>\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\/operator\/comparison-operators\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"An Overview of Bash Comparison [Conditional] Operators - LinuxSimply\" \/>\n<meta property=\"og:description\" content=\"Bash comparison operators help programmers to compare string and number and take necessary result from the comparison result.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/dasgupta.susmit\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-06T08:10:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-02T04:44:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/bash-comparison-operators-feature-image.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=\"Susmit Das Gupta\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Susmit Das Gupta\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 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\\\/operator\\\/comparison-operators\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/\"},\"author\":{\"name\":\"Susmit Das Gupta\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/38abbef9a1053d9faec8935dc39f10fa\"},\"headline\":\"An Overview of Bash Comparison [Conditional] Operators\",\"datePublished\":\"2023-11-06T08:10:49+00:00\",\"dateModified\":\"2024-04-02T04:44:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/\"},\"wordCount\":1208,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/bash-comparison-operators-feature-image.png\",\"keywords\":[\"bash operator\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/\",\"name\":\"An Overview of Bash Comparison [Conditional] Operators - LinuxSimply\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/bash-comparison-operators-feature-image.png\",\"datePublished\":\"2023-11-06T08:10:49+00:00\",\"dateModified\":\"2024-04-02T04:44:51+00:00\",\"description\":\"Bash comparison operators help programmers to compare string and number and take necessary result from the comparison result.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/bash-comparison-operators-feature-image.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/bash-comparison-operators-feature-image.png\",\"width\":400,\"height\":400,\"caption\":\"bash comparison operators\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/comparison-operators\\\/#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 Operator\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/operator\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"An Overview of Bash Comparison [Conditional] Operators\"}]},{\"@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\\\/38abbef9a1053d9faec8935dc39f10fa\",\"name\":\"Susmit Das Gupta\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Susmit-Das-Gupta-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Susmit-Das-Gupta-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Susmit-Das-Gupta-II-96x96.png\",\"caption\":\"Susmit Das Gupta\"},\"description\":\"Hello everyone. I am Susmit Das Gupta, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Mechanical Engineering graduate from Bangladesh University of Engineering and Technology. Besides my routine works, I find interest in going through new things, exploring new places, and capturing landscapes. Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dasgupta.susmit\",\"https:\\\/\\\/www.instagram.com\\\/susmit_dasgupta\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/susmitdasgupta\\\/\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/susmit\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"An Overview of Bash Comparison [Conditional] Operators - LinuxSimply","description":"Bash comparison operators help programmers to compare string and number and take necessary result from the comparison result.","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\/operator\/comparison-operators\/","og_locale":"en_US","og_type":"article","og_title":"An Overview of Bash Comparison [Conditional] Operators - LinuxSimply","og_description":"Bash comparison operators help programmers to compare string and number and take necessary result from the comparison result.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/dasgupta.susmit","article_published_time":"2023-11-06T08:10:49+00:00","article_modified_time":"2024-04-02T04:44:51+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/bash-comparison-operators-feature-image.png","type":"image\/png"}],"author":"Susmit Das Gupta","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Susmit Das Gupta","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/"},"author":{"name":"Susmit Das Gupta","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/38abbef9a1053d9faec8935dc39f10fa"},"headline":"An Overview of Bash Comparison [Conditional] Operators","datePublished":"2023-11-06T08:10:49+00:00","dateModified":"2024-04-02T04:44:51+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/"},"wordCount":1208,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/bash-comparison-operators-feature-image.png","keywords":["bash operator"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/","name":"An Overview of Bash Comparison [Conditional] Operators - LinuxSimply","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/bash-comparison-operators-feature-image.png","datePublished":"2023-11-06T08:10:49+00:00","dateModified":"2024-04-02T04:44:51+00:00","description":"Bash comparison operators help programmers to compare string and number and take necessary result from the comparison result.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/bash-comparison-operators-feature-image.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/11\/bash-comparison-operators-feature-image.png","width":400,"height":400,"caption":"bash comparison operators"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/comparison-operators\/#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 Operator","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/operator\/"},{"@type":"ListItem","position":4,"name":"An Overview of Bash Comparison [Conditional] Operators"}]},{"@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\/38abbef9a1053d9faec8935dc39f10fa","name":"Susmit Das Gupta","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Susmit-Das-Gupta-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Susmit-Das-Gupta-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Susmit-Das-Gupta-II-96x96.png","caption":"Susmit Das Gupta"},"description":"Hello everyone. I am Susmit Das Gupta, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Mechanical Engineering graduate from Bangladesh University of Engineering and Technology. Besides my routine works, I find interest in going through new things, exploring new places, and capturing landscapes. Read Full Bio","sameAs":["https:\/\/www.facebook.com\/dasgupta.susmit","https:\/\/www.instagram.com\/susmit_dasgupta\/","https:\/\/www.linkedin.com\/in\/susmitdasgupta\/"],"url":"https:\/\/linuxsimply.com\/author\/susmit\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/26135","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\/314894"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=26135"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/26135\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/26161"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=26135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=26135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=26135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}