{"id":357,"date":"2006-11-21T00:34:15","date_gmt":"2006-11-21T05:34:15","guid":{"rendered":"http:\/\/crazedmonkey.com\/blog\/programming\/multiple-expression-if-statement-in-bash.html"},"modified":"2006-11-21T00:34:15","modified_gmt":"2006-11-21T05:34:15","slug":"multiple-expression-if-statement-in-bash","status":"publish","type":"post","link":"http:\/\/crazedmonkey.com\/blog\/programming\/multiple-expression-if-statement-in-bash.html","title":{"rendered":"Multiple expression if statement in BASH"},"content":{"rendered":"<p>It&#8217;s not very well documented, but it&#8217;s possible to include multiple conditional expressions in a single if statement in <a href=\"http:\/\/www.gnu.org\/software\/bash\/\" title=\"BASH - GNU Project - Free Software Foundation\">BASH<\/a>.  By multiple conditional expressions, I mean something like:<\/p>\n<pre><code>if foo = 1 or bar = 3 or abc = 4 then\n    print Hello World\nend if<\/code><\/pre>\n<p>You can do boolean OR in BASH by using the <code>-o<\/code> operator.  The following is the above code written in BASH:<\/p>\n<pre><code>if [ $foo -eq 1 -o $bar -eq 3 -o $abc -eq 4 ]; then\n    echo Hello World\nfi<\/code><\/pre>\n<p>For boolean AND, use the <code>-a<\/code> operator.  You can also intermix the two.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s not very well documented, but it&#8217;s possible to include multiple conditional expressions in a single if statement in <a href=\"http:\/\/www.gnu.org\/software\/bash\/\" title=\"BASH - GNU Project - Free Software Foundation\">BASH<\/a>. By multiple conditional expressions, I mean something like:<\/p>\n<p> if foo = 1 or bar = 3 or abc = 4 then print Hello World end if&nbsp;&hellip;&nbsp;<a class=\"read_more\" href=\"http:\/\/crazedmonkey.com\/blog\/programming\/multiple-expression-if-statement-in-bash.html\" rel=\"bookmark\" title=\"Continue reading &ldquo;Multiple expression if statement in BASH&rdquo;\"><span>Read more<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts\/357"}],"collection":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/comments?post=357"}],"version-history":[{"count":0,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts\/357\/revisions"}],"wp:attachment":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/media?parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/categories?post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/tags?post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}