{"id":79173,"date":"2021-06-09T00:30:39","date_gmt":"2021-06-09T06:00:39","guid":{"rendered":"https:\/\/www.whizlabs.com\/blog\/?p=79173"},"modified":"2022-09-07T22:43:25","modified_gmt":"2022-09-08T04:13:25","slug":"all-bash-if-statements","status":"publish","type":"post","link":"https:\/\/www.whizlabs.com\/blog\/all-bash-if-statements\/","title":{"rendered":"All Bash If Statements"},"content":{"rendered":"<p><i><span style=\"font-weight: 400;\">Looking for a <a href=\"https:\/\/www.whizlabs.com\/blog\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash scripting tutorial<\/a> to learn various bash statements? Here\u2019s the detailed tutorial on Bash If statements, let\u2019s dive in!<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">Bash If\u00a0statements are quite useful to help you adapt the ways using which you can automate specific tasks. Bash If and Bash if-else statements allow people to make decisions within the bash scripts. Those statements put up a decision of whether to run a code or not based upon the condition set upon the statements.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The Bash If statements are often combined with certain loops to help you prepare complex scripts for solving large tasks. Even though their syntax is simple, they are used in diverse conditions across the Bash Scripting world. And, this article aims to cover the maximum possible Bash If statements for you.<\/span><\/p>\n<p><b style=\"font-family: 'Open Sans', arial, sans-serif; font-size: 27px; letter-spacing: -0.02em;\">Bash If and Bash If-Else Statements upon Diverse Conditions<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The difference between Bash If and\u00a0Bash If-else\u00a0syntax is very minimal but can change the entire usability of the bash script. With Bash If, the statement will be executed only if the condition is true. In case the condition is false, then the statement will be ignored. But, with Bash If-else, there are two statements specified within the bash scripts for one condition. If the condition is true, then the first statement will be executed, but if the condition is false, then the second statement will be executed. Hence, now you know that the\u00a0Bash conditions\u00a0are responsible for executing the If and If-else statements.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you intend to use Bash for scripting purposes, then you cannot deny the use of numerous conditions. At times, some conditions have complex syntaxes that make it difficult for beginners to understand. Therefore, here is the syntax and a brief explanation of the most commonly used Bash If statements:<\/span><\/p>\n<ol>\n<li>\n<h6><b> If [ $foo -ge 3]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This condition mentioned within the example is a command. Surrounding a comparison with the use of square brackets is the same as using test commands. In this condition, if \u2018$foo\u2019 is equal to or greater than 3, the statement after \u2018then\u2019 will execute.\u00a0\u00a0<\/span><\/p>\n<ol start=\"2\">\n<li>\n<h6><b>if test $foo -ge 3; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It is the same condition common as the first one, without square brackets, that makes it necessary for the use of test commands.<\/span><\/p>\n<ol start=\"3\">\n<li>\n<h6><b>if [ -f regularfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This condition is true only if the file with name \u2018regularfile\u2019 exists and is actually a regular file. A regular file should not be a character\/block device or a directory.<\/span><\/p>\n<ol start=\"4\">\n<li>\n<h6><b>if [ -r readablefile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The above condition is counted as true if the file with name \u2018readablefile\u2019 exists and is actually readable.<\/span><\/p>\n<ol start=\"5\">\n<li>\n<h6><b>if &lt;condition&gt;; then &lt;commands&gt; fi<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It is the basic syntax of Bash If.<\/span><\/p>\n<ol start=\"6\">\n<li>\n<h6><b>if [ -r somefile ]; then | content=$ (cat somefile) elif<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">If this condition is true, only if there is a readable file with the name \u2018somefile.\u2019 If it is available, then the condition will read into the variable. But, if not, then the program will proceed to check if the file actually exists by compiling the second statement.<\/span><\/p>\n<ol start=\"7\">\n<li>\n<h6><b>if [ \u201cstringvar\u201d == \u201ctux\u201d ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This statement implies the use of quotes for using strings in your conditions with the\u00a0<\/span><b>bash if<\/b><span style=\"font-weight: 400;\">\u00a0statements.<\/span><\/p>\n<ol start=\"8\">\n<li>\n<h6><b>if [ ! -f regularfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This statement implies that you can invert the purpose of the condition by adding an exclamation or \u2018!\u2019 mark within the brackets.<\/span><\/p>\n<ol start=\"9\">\n<li>\n<h6><b>if [ $foo -ge 3 -a $foo -lt 10]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This statement implies a combination of the conditions with the use of a single bracket syntax that uses \u2018-a\u2019 for AND &amp; \u2018-o\u2019 for OR. This condition will turn out to be true only if the $foo consists of an integer that is equal to or greater than 3 and\u00a0is less than 10. There are numerous combinations that you can try with such syntax!<\/span><\/p>\n<ol start=\"10\">\n<li>\n<h6><b> if [ -L symboliclink ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It is a file-based condition that allows you to run different checks upon a file. This condition is true only if the symbolic link file with name \u2018symboliclink\u2019 in this condition exists.<\/span><\/p>\n<ol start=\"11\">\n<li>\n<h6><b> if [ -z &#8220;$emptystring&#8221; ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It is a string-based condition, and this statement allows you to check a string or compare multiple strings. This condition is true only if the $emptystring is an uninitialized variable or is an empty string.<\/span><\/p>\n<ol start=\"12\">\n<li>\n<h6><b> if [ &#8220;$stringvar1&#8221; == &#8220;cheese&#8221; ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It is also another type of string-based condition, and it is true if the \u2018$stringvar1\u2019 input consists of \u2018cheese\u2019 as its string.<\/span><\/p>\n<ol start=\"13\">\n<li>\n<h6><b> if [ $num -lt 1 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It is the arithmetic or number-based conditions, and this statement allows comparison of integer numbers. This condition is counted as true only if the entered number is less than 1.<\/span><\/p>\n<ol start=\"14\">\n<li>\n<h6><b> if [[ &#8220;$stringvar&#8221; == *string* ]]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It is the double-bracket syntax for\u00a0<\/span><b>Bash If<\/b><span style=\"font-weight: 400;\">\u00a0statements. It serves as the enhanced version and technically has similar features but with certain differences. The double bracket syntax intends to feature \u2018shell globbing.\u2019 Moreover, this condition will be true if $stringvar has a phrase \u2018string.\u2019<\/span><\/p>\n<ol start=\"15\">\n<li>\n<h6><b> if [[ &#8220;$stringvar&#8221; == *[sS]tring* ]]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This condition is using diverse shell globbing techniques. Referring to this example condition, with shell globbing, you can check or match both \u2018String\u2019 and \u2018string\u2019 using this syntax. The condition will be true even if \u2018$stringvar\u2019 has \u2018String\u2019 or \u2018string.\u2019<\/span><\/p>\n<ol start=\"16\">\n<li>\n<h6><b> if [ -a *.sh ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This condition explains the single bracket syntax for executing the file specified within the conditions. This condition will be true if there is only one file within the directory that consists of an extension \u2018.sh.\u2019 In case there are several \u2018.sh\u2019 files within the directory, bash will put up an error message and will stop the execution. It is because the *.sh command is expanded onto the files within a directory, and this can be prevented with the use of a double bracket.<\/span><\/p>\n<ol start=\"17\">\n<li>\n<h6><b> if [[ -a *.sh ]]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This condition explains the double-bracket syntax to avoid expanding the filename within conditions. This condition will be true if a file is present in the directory with extension \u2018*.sh.\u2019 It will execute and display the file, irrespective of whether there are other .sh files or not. The asterisk sign is quite important within the double bracket syntax to avoid expansion of the file names within double-bracket syntax.<\/span><\/p>\n<ol start=\"18\">\n<li>\n<h6><b> if [[ $num -eq 3 &amp;&amp; &#8220;$stringvar&#8221; == foo ]]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This condition explains the use of combining operators \u2018&amp;&amp;\u2019 and \u2018||.\u2019 This condition has used \u2018&amp;&amp;\u201d that says that the statement will be true only if \u2018$num\u2019 is equal to 3 and the \u2018$stringvar\u2019 is equal to string \u2018foo\u2019. The AND and OR operators, \u2018-a\u2019 and \u2018-o\u2019 is also supported. But, the \u2018&amp;&amp;\u2019 and \u2018||\u2019 are mostly preferred for statements with double-bracket syntax. The AND operators will always be executed first over the OR operators.<\/span><\/p>\n<ol start=\"19\">\n<li>\n<h6><b> if (( $num &lt;= 5 )); then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">It is the double-parenthesis syntax, meant especially for the arithmetic conditions or number-based conditions. This condition is considered true if \u2018$num\u2019 is less than\/equal to 5. This syntax is way more common for programmers over time. It uses some of the most commonly used operators such as \u201c&lt;, &gt;=, and ==. This syntax will support the use of \u2018&amp;&amp;\u2019 and \u2018||,\u2019 but you cannot use \u2018-a\u2019 and \u2018-o\u2019 on it. The use of this syntax is equivalent to \u2018Let\u2019 command within bash.<\/span><\/p>\n<h2><b>File Based Bash If Conditions<\/b><\/h2>\n<ol start=\"20\">\n<li>\n<h6><b>if [ -a existingfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This condition is counted as true if the file with the name \u2018existingfile\u2019 exists within the directory.<\/span><\/p>\n<ol start=\"21\">\n<li>\n<h6><b>if [ -b blockspecialfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if the block special file with the name \u2018blockspecialfile\u2019 exists within the working directory.<\/span><\/p>\n<ol start=\"22\">\n<li>\n<h6><b>if [ -c characterspecialfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true only if the character special file with the name \u2018characterspecialfile\u2019 is available within the search directory.<\/span><\/p>\n<ol start=\"23\">\n<li>\n<h6><b>if [ -d directory ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true; if the file name \u2018directory\u2019 exists but is conditioned, it should actually be a directory file.<\/span><\/p>\n<ol start=\"24\">\n<li>\n<h6><b>if [ -e existingfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">If the file named \u2018existingfile\u2019 exists within the directory, then this condition will execute as true.<\/span><\/p>\n<ol start=\"25\">\n<li>\n<h6><b>if [ -g sgidfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">If the file with the name \u2018sgidfile\u2019 is a set-group-Id and exists within the search directory, then this condition will execute as true.<\/span><\/p>\n<ol start=\"26\">\n<li>\n<h6><b>if [ -G fileownedbyeffectivegroup ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This condition is true if the file named \u2018fileownedbyeffectivegroup\u2019 is available and is completely owned by the group ID.<\/span><\/p>\n<ol start=\"27\">\n<li>\n<h6><b>if [ -k stickyfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">If the file named \u2018stickyfile\u2019 belongs to the sticky bit set and is available within the directory, then the condition is true.<\/span><\/p>\n<ol start=\"28\">\n<li>\n<h6><b>if [ -N modifiedsincelastread ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true only if the file with name \u2018modifiedsincelastread\u2019 exists and was actually modified after it was read last.<\/span><\/p>\n<ol start=\"29\">\n<li>\n<h6><b>if [ -O fileownedbyeffectiveuser ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is termed to be true if the file with name \u2018fileownedbyeffectiveuser\u2019 is owned by the effective user and is available within the directory.<\/span><\/p>\n<ol start=\"30\">\n<li>\n<h6><b>if [ -p namedpipe ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The file \u2018namedpipe\u2019 should be a named pipe and must be available within the directory for this condition to be true.<\/span><\/p>\n<ol start=\"31\">\n<li>\n<h6><b>if [ -s nonemptyfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">If the file with name \u2018nonemptyfile\u2019 is of size more than 0 bytes and is available within the directory, then the condition is true.<\/span><\/p>\n<ol start=\"32\">\n<li>\n<h6><b>if [ -S socket ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">A socket file within the directory with file name \u2018socket\u2019 can make this condition true.<\/span><\/p>\n<ol start=\"33\">\n<li>\n<h6><b>if [ newerfile -nt olderfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if the file with name \u2018newerfile\u2019 was modified recently as compared to \u2018olderfile.\u2019 It is also true if the \u2018olderfile\u2019 doesn\u2019t exist and \u2018newerfile\u2019 does.<\/span><\/p>\n<ol start=\"34\">\n<li>\n<h6><b>if [ olderfile -ot newerfile ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if the file with name \u2018olderfile\u2019 was modified long ago than \u2018newerfile.\u2019 It is also true if the \u2018newerfile\u2019 is present in the directory and \u2018olderfile\u2019 doesn\u2019t exist.<\/span><\/p>\n<blockquote><p><a href=\"https:\/\/www.whizlabs.com\/bash-scripting-fundamentals\/\" target=\"_blank\" rel=\"noopener\">Whizlabs Bash Scripting Fundamentals<\/a> course intends to help you learn how to create shell scripts using Bash to automate tasks on a UNIX system. Check it out now!<\/p><\/blockquote>\n<h2><b>String-Based Bash If Conditions<\/b><\/h2>\n<ol start=\"35\">\n<li>\n<h6><b>if [ STRING1 == STRING2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if \u2018STRING1\u2019 is entirely same as that of \u2018STRING2\u2019.<\/span><\/p>\n<ol start=\"36\">\n<li>\n<h6><b>if [ STRING1 != STRING2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if \u2018STRING1\u2019 is not same as that of \u2018STRING2\u2019.<\/span><\/p>\n<ol start=\"37\">\n<li>\n<h6><b>if [ STRING1 &gt; STRING2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if the sorting of \u2018STRING1\u2019 is executed after \u2018STRING2\u2019 within the current locale.<\/span><\/p>\n<ol start=\"38\">\n<li>\n<h6><b>if [ STRING1 &lt; STRING2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if the sorting of \u2018STRING1\u2019 is executed before \u2018STRING2\u2019, within the current locale.<\/span><\/p>\n<ol start=\"39\">\n<li>\n<h6><b>if [ -n NONEMPTYSTRING ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if the string named \u2018NONEMPTYSTRING\u2019 has a length more than 0 (ZERO).<\/span><\/p>\n<ol start=\"40\">\n<li>\n<h6><b>if [ -z EMPTYSTRING ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true only if the string named \u2018EMPTYSTRING\u2019 is of Zero-length.<\/span><\/p>\n<ol start=\"41\">\n<li>\n<h6><b>if [[ STRING1 =~ REGEXPATTERN ]]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This statement works only with double-bracket syntax. This condition is true only if the string named \u2018STRING1\u2019 matches with the REGEXPPATTERN.<\/span><\/p>\n<h2><b>Arithmetic or Number-Based Bash If Conditions<\/b><\/h2>\n<ol start=\"42\">\n<li>\n<h6><b>if [ NUM1 -eq NUM2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if \u2018NUM1\u2019 is same as \u2018NUM2\u2019.<\/span><\/p>\n<ol start=\"43\">\n<li><b><\/b><strong>if [ NUM1 -ne NUM2 ]; then<\/strong><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if \u2018NUM1\u2019 is not same or equal to that of \u2018NUM2\u2019.<\/span><\/p>\n<ol start=\"44\">\n<li>\n<h6><b>if [ NUM1 -gt NUM2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if \u2018NUM1\u2019 is a greater value than that of \u2018NUM2\u2019.<\/span><\/p>\n<ol start=\"45\">\n<li>\n<h6><b>if [ NUM1 -ge NUM2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if \u2018NUM1\u2019 is greater than that of \u2018NUM2\u2019 or are equal to one another.<\/span><\/p>\n<ol start=\"46\">\n<li>\n<h6><b>if [ NUM1 -lt NUM2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if value in \u2018NUM1\u2019 is less than that of value in \u2018NUM2\u2019.<\/span><\/p>\n<ol start=\"47\">\n<li>\n<h6><b>if [ NUM1 -le NUM2 ]; then<\/b><\/h6>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The condition is true if the value in \u2018NUM1\u2019 is less than that of \u2018NUM2\u2019 or if both the numbers are equal to one another.<\/span><\/p>\n<h2><b>Final Words<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">These are just a few of the commonly preferred\u00a0Bash If\u00a0statements that are popularly used for usual Bash scripting. There are more to it, following to which you will also be using If-else\u00a0Bash conditions\u00a0for putting up more efficient and complex statements for desired output. So, make sure that you use them and utilize them to master the fundamentals of using if statements in bash scripting.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Are you aspiring to learn Bash scripting to create shell scripts to automate tasks on a UNIX system? If yes, enroll in the <a href=\"https:\/\/www.whizlabs.com\/bash-scripting-fundamentals\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Fundamentals training course<\/a> and learn the fundamentals of Bash scripting at Whizlabs.\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Looking for a Bash scripting tutorial to learn various bash statements? Here\u2019s the detailed tutorial on Bash If statements, let\u2019s dive in! Bash If\u00a0statements are quite useful to help you adapt the ways using which you can automate specific tasks. Bash If and Bash if-else statements allow people to make decisions within the bash scripts. Those statements put up a decision of whether to run a code or not based upon the condition set upon the statements. The Bash If statements are often combined with certain loops to help you prepare complex scripts for solving large tasks. Even though their [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":79174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[14],"tags":[4392,4398,4395,4393,4394,4396,4397],"class_list":["post-79173","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-all-bash-if-statements","tag-arithmetic-or-number-based-bash-if-conditions","tag-bash-conditions","tag-bash-if","tag-bash-if-else","tag-file-based-bash-if-conditions","tag-string-based-bash-if-conditions"],"uagb_featured_image_src":{"full":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",600,315,false],"thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements-150x150.png",150,150,true],"medium":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements-300x158.png",300,158,true],"medium_large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",600,315,false],"large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",600,315,false],"1536x1536":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",600,315,false],"2048x2048":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",600,315,false],"profile_24":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",24,13,false],"profile_48":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",48,25,false],"profile_96":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",96,50,false],"profile_150":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",150,79,false],"profile_300":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",300,158,false],"tptn_thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements-250x250.png",250,250,true],"web-stories-poster-portrait":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",600,315,false],"web-stories-publisher-logo":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",96,50,false],"web-stories-thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/06\/All-Bash-If-Statements.png",150,79,false]},"uagb_author_info":{"display_name":"Pavan Gumaste","author_link":"https:\/\/www.whizlabs.com\/blog\/author\/pavan\/"},"uagb_comment_info":1,"uagb_excerpt":"Looking for a Bash scripting tutorial to learn various bash statements? Here\u2019s the detailed tutorial on Bash If statements, let\u2019s dive in! Bash If\u00a0statements are quite useful to help you adapt the ways using which you can automate specific tasks. Bash If and Bash if-else statements allow people to make decisions within the bash scripts.&hellip;","_links":{"self":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/79173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/comments?post=79173"}],"version-history":[{"count":5,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/79173\/revisions"}],"predecessor-version":[{"id":84716,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/79173\/revisions\/84716"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media\/79174"}],"wp:attachment":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media?parent=79173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/categories?post=79173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/tags?post=79173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}