The script assigns the value of $1 to the year variable.3. Enter the following into your command line: You can use an if statement inside another if statement (it’s ok to have nested if statements). Bash performs variable substitution before the command is really executed. Introduction to If Else in Shell Scripting “If else” is a conditional or control statement in the programming language. Your Own Linux..! You need to put the ELSE in it's own statement block: IF (@CCTable = 'Claiminassoc') BEGIN IF ( @ClaimCenterField = 'ClaimID' AND @VALUE ='Claim') These statements execute different blocks of code, depending upon whether a condition (or a boolean expression) provided by the … Nested if statements might be nice, but as soon as you are confronted with a couple of different possible actions to take, they tend to confuse. Bash Script 'if-else' Statements - Conditional Statements are those which help us take certain decisive actions against certain different conditions. You can have as many levels of nested if statements as you can track. Then the second pass of the outer loop triggers the inner loop again. This is what it means: a bash nested for loop statement runs a command within another loop. Nested If/Else. A nested loop is a loop within a loop, an inner loop within the body of an outer one. Batch Script - Nested If Statements - Sometimes, there is a requirement to have multiple â ifâ statement embedded inside each other. These statements execute different blocks of code, depending upon whether a condition (or a boolean expression) provided by the programmer evaluates to true or false. 'Simple If', 'If-else', 'If-elif-else' and 'Nested If' Statements in Bash Scripting Unknown October 10, 2013 linux commands , shell scripting No comments The following pseudo-code shows my intention. Active today. Bash Nested if statement if command1 then commands else if command2 then commands else commands fi fi You can write if statement inside else block and if block and thus nested any number of if statement. Bash If Else : If else statement is used for conditional branching of program (script) execution in sequential programming. Multiple IF functions can be nested together to allow for multiple criteria. If elif if ladder appears like a conditional ladder. If statements (and, closely related, case statements) allow us to make decisions in our Bash scripts. In 'nested-if' statements, there are one or more 'if-then-else' or 'if-elif-else' statements nested in one 'if-then-else' or 'if-elif-else' statement. Nested if statement best example. If statement and else statement could be nested in bash. When you integrate nested loops in bash scripting, you are trying to make a command run inside another command. Multiple IF functions can be nested together to allow for multiple criteria. This is the basic if condition, where the code block executes based on the result of defined condition. nested if statement; 1. In Bash else-if, there can be multiple elif blocks with a boolean expression for each of them. In “Nested if-else”, we are validating the two conditions. For example, a{d,c,b}e expands into `ade ace abe'. Bash Script 'if-else' Statements - Conditional Statements are those which help us take certain decisive actions against certain different conditions. Registered User. Bash recognizes when the first commands are successfully executed; then, it refers to the inner loop to continue, while leaving the outer loop alone. You can also use an if statement within another if statement. Note: Instead of using exit status code of a command Bash provides test command that enables you to evaluate any condition. Posts: 45 Thanks Given: 9. Copyright © var creditsyear = new Date();document.write(creditsyear.getFullYear()); It is used to exit from a for, while, until, or select loop. Advanced Bash-Scripting Guide: Prev: Chapter 7. Here we will learn about IF/Else statement for Strings, Files, Errors and Nested If . If elif if ladder appears like a conditional ladder. A nested if statement is where you have an if statement inside of an existing if statement. Batch Script - Nested If Statements - Sometimes, there is a requirement to have multiple â ifâ statement embedded inside each other. Using the case statement instead of nested if statements will help you make your bash scripts more readable and easier to maintain. Nested if statement best example. The nested loop (also called the inner loop) iterates through its values for each iteration of the outer loop.Notice that there’s no difference between the do and done commands for the two loops. Nested if question BASH | Post 302490009 by lio123 on Sunday 23rd of January 2011 09:00:02 AM That is to say, it is a loop that exists inside an outer loop. another nested IF formula to work out off-peak call charges. 45, 0. They are useful for when you want to repeat something serveral times for several things. If the expression evaluates to true, statements of if block are executed. The nested loop, or inner loop, will run repeatedly through its values for each time the outer loop is triggered. BASH – If statement and comparison operators by sanaswati on 03/07/2012 in bash shell scripting You can use if statements without any brackets or within [] or [[]] or (). The syntax is as you'd expect, just simply placing the statements inside each other, and the following is a script demonstrating this: #!/bin/bash #declare variable choice and initialise value as 4 choice=4 When you integrate nested loops in bash scripting, you are trying to make a command run inside another command. For example, take a look at the following weather.sh bash script: #!/bin/bash TEMP=$1 if [ $TEMP -gt 5 ]; then if [ $TEMP -lt 15 ]; then echo "The weather is cold." If you constantly deal with bash scripts, you will obviously come in contact with many terms, commands, and techniques. Ask Question Asked today. How this works is that the first pass of the outer loop triggers the inner loop, which executes to completion. This plays a different action or computation depending on whether the condition is … You can have as many levels of nested if statements as you can track. In the following example:1. You input the year as a command-line argument.2. Of course there are going to be points where you want nested If/Else statements rather than just single If/Else statements. 'Simple If', 'If-else', 'If-elif-else' and 'Nested If' Statements in Bash Scripting, Getting Started - Basic Linux Shell Scripting Language, Basic Linux Shell Scripting Language - Part II, Basic Linux Shell Scripting Language - Part III, Basic Linux Shell Scripting Language : Introduction to 'FOR' Loops, Basic Linux Shell Scripting Language : 'While' Loops, Basic Linux Shell Scripting Language : 'Until' Loops, Basic Linux Shell Scripting Language : 'Case' Statement, Basic Linux Shell Scripting Language : 'Select Loop', Sed Command in Linux - Append and Insert Lines to a File, How to Install or Upgrade Python in Linux Systems, /etc/passwd File Format in Linux Explained, Sed Command in Linux - Delete Lines from a File. BASH – If statement and comparison operators by sanaswati on 03/07/2012 in bash shell scripting You can use if statements without any brackets or within [] or [[]] or (). In this article, we will learn Conditional Statements, its different types, their syntax and example of each of them. In Bash, break and continue statements allows you to control the loop execution. For example, take 3 numeric values as input and check the greatest value. For ranges, Bash evaluates as little as possible, i.e., if the first part is out of range, the second won't be evaluated. 2. Bash Nested If Else. For example, create a shell script called nestedfor.sh: The keyword “fi” indicates the end of the inner if statement and all if statement should end with the keyword “fi”. Quick note: it is possible to put multiple loops inside one another. DiskInternals Linux Reader is arguably the best and most intuitive software app that lets you access and view files saved on Ext2/3/4 partitions on a dual-boot Windows PC or virtual machine. if [ condition ] then if [ condition ] then else fi else if [ condition ] then fi fi. And if the command returns a non-zero exit status code, then the commands written in the else section is executed. The bash case statement is generally used to simplify complex conditionals when you have multiple different choices. Using case statements. If the result is true the code block will be executed, and if result is false program will bypass the code block. We have already seen these statements in some of our previous articles on Basic Linux Shell Scripting Language. I have a huge file, I would like to read 1 line at a time, and use sed to change anything in that line matching a list in my file, and putting the changed output to yet another file. If statement and else statement could be nested in bash. 7.3.1. FREE DOWNLOADVer 4.7, Win This is a great way to test if a bash script was given arguments or not, as a bash scripts arguments are placed into variables $1, $2, $3 and so on automatically. Nested for loops means loop within loop. Bu the first one (sync datadirs) is not working. Example files: BIGFILE.txt lets just say, lots of data SEARCHTERMS.txt this that The second one (sync databases) is working fine. The keyword “fi” indicates the end of the inner if statement and all if statement should end with the keyword “fi”. /bin/sh must be linked to bash-compatible shell, and in any system in the past decade it is definitely NOT the old Bourne shell. Nested if statement to declare student results. The bash shell knows when the first done command is executed that it refers to the inner loop and not the outer loop.. If the first “if_else” condition may false then the first condition of the “else” part will execute. Nested if statement to declare student results. It is used to exit from a for, while, until, or select loop. Nested Variables in Shell Scripting. The “if then elif then else fi” example mentioned in above can be converted to the nested if as shown below. nested logical expression in bash shell I would like to nest logical expressions for arguments of the "test" command on bash. Following is the syntax of Else If statement in Bash Shell Scripting. For … There is no ELSE IF statement in TSQL. Join Date: Jan 2011. I don't think {...} is the problem. Different bash commands can cause your script not to run as expected if not properly entered. Nested if/then Condition Tests Condition tests using the if/then construct may be nested. Also, there is usually no difference between the “do” and “done” commands for both loops. bash: nested WHILE READ sections. ... Browse other questions tagged bash shell-script scripting inotify or ask your own question. They allow us to decide whether or not to run a piece of code based upon conditions that we may set. The Excel IF function statement allows you to make a logical comparison between a value and what you expect by testing for a condition and returning a result if True or False. Following is the general form of this statement. It is quite simple: a nested loop is an inner loop placed inside another one (loop). Nested if/then Condition Tests. The “if then elif then else fi” example mentioned in above can be converted to the nested if as shown below. The Bash case statement has a similar concept with the Javascript or C switch statement. Upgrade to PROFrom $29.95, EFS Recovery - repair your EFS files from damaged or formatted disks, RAID Array Data Recovery - make your RAID arrays alive, VMFS tools - repair your data from VMFS, VMDK, ESX(i), vSphere disks, Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows. Tests: ... 7.4. It is quite simple: a nested loop is an inner loop placed inside another one (loop). Our generic nested IF formula evaluates 3 conditions, and returns 4 different results (result 4 is returned if none of the conditions is TRUE). Usually though in a bash script you want to check if the argument is empty rather than if it is not empty, to do this you can use the … There's no specific number of nested loops you can have inside another loop; however, the indentations will become very complicated to track as the number of nested loops keep increasing. nested logical expression in bash shell I would like to nest logical expressions for arguments of the "test" command on bash. Hello World Bash Shell Script Attention: For more verbose and beginner style Bash scripting tutorial visit our Bash Scripting Tutorial for Beginners First you need to find out where is your bash interpreter located. Literally, every programming command is handy for a particular purpose. Bash (AKA Bourne Again Shell) is a type of interpreter that processes shell commands. ... Nested if/else conditions. Bash Else If. Nested loop -bash. I disagree. Beware of infinite loops! The script assigns the value of … Top Forums Shell Programming and Scripting Nested if question BASH # 1 01-23-2011 lio123. You input the year as a command-line argument. The -eq in the statement is an operator or in simpler terms a comparison, it is used to tell bash an operation to perform to find true or false. If the command runs successfully and returns an exit status code of zero, then the commands listed between then and else will be executed. In D4 write a formula to calculate the peak call charges (minutes * price per minute) See also how to pass arguments to a bash script , which shows how to use conditionals to process parameters passed from the command line . Simplified conditions. Nested if Statements. 11.2. That is to say, it is a loop that exists inside an outer loop. Notes. In this tutorial, you will explore the three different bash loop structures. The newer IFS … The program worked just fine with just one if statement. inotifywait script not working as expected (nested if-then statements) ... #!/bin/bash # Quickly create and activate a WiFi hotspot - optionally defining SSID and password - and deactivate it again when you don't need it anymore. Bash nested if Statements. Using the same information shown above, in cell C5, write a nested IF that finds the correct off-peak rate from the Tariff table. You can use an if statement inside another if statement (it’s ok to have nested if statements). Decision making is one of the most fundamental concepts of computer programming. Using nested if statements in bash. Here is the last article on Linux Variables where we are going to see variables substitution and variables defined in Shell before closing this topic. Bash Guide for Beginners; Prev: Chapter 7. In Bash else-if, there can be multiple elif blocks with a boolean expression for each of them. Learn Linux shell scripting for & while loops , nested loops, using break & continue commands, redirect loop output, and get directory files using loops. I am using the following nested loop for i in {1..3} do for y in {1..3} do if ; then echo P0${i}R${y}.fas mv P0${i}R${y}.fas P${i}R${y}.fas read -t 5 fi done done I was wondering if I can use a character such as * or ? Syntax of Bash Else IF – elif. It is possible to nest multiple if-else conditions inside one another. Loops have a variety of use cases. 7.3.1. Nested for loops means loop within loop. elif [ $TEMP … Bash – if Statement Example. It says: rsync: command not found. The net result is identical to using the && compound comparison operator above. The Overflow Blog Podcast 296: Adventures in Javascriptlandia. If this bothers you, you can add line breaks inside the formula to "line up" the tests and results. Bash Guide for Beginners; Prev: Chapter 7. Translated into a human language, this nested IF statement tells Excel to do the following: A nested loop is useful because it allows the programmer to use the best attributes of any type of loop, including the while loop and for loop. Conditional statements: Next: 7.3. Using DiskInternals Linux Reader, it is possible to open your Linux files on Windows computers. I am using the following nested loop for i in {1..3} do for y in {1..3} do if ; then echo P0${i}R${y}.fas mv P0${i}R${y}.fas P${i}R${y}.fas read -t 5 fi done done I was wondering if I can use a character such as * or ? Making nested IFs easier to read. Adapter to convert a 45-degree angle wall electrical plug into a straight plug There must be something wrong with the way I implemented the nested if – Ptheguy Jun 1 '17 at 16:46 Last Activity: 18 August 2011, 8:44 PM EDT. The ability to loop is a very powerful feature of bash scripting. However, if the outer or inner loop breaks within the running time, the process will be interrupted. Bash if-then-else statement if command then commands else commands fi. | Powered by Blogger. ksh93 and mksh always evaluate the subscript parts even if the parameter is unset. With nested if one condition goes true then only check another condition. Bash break Statement # The break statement terminates the current loop and passes program control to the command that follows the terminated loop. s The syntax of the break statement takes the following form: Nested loop -bash. If the first “if_else” condition will true then only the next “if_else” condition will validate. inotifywait - need help with nested if statements. The results of each expanded string are not sorted; left to right order is preserved. However, an if statement can be nested with arbitrary complexity. For example see the bash(1) manpage: Brace expansions may be nested. When you have a nested loop, here is what happens: the outer loop triggers a command, and the nested (inner) loop executes the command to complete. The echo statement prints its argument, in this case, the value of the variable count , to the terminal window. Conditional Statements are those which execute different blocks of code depending upon whether a Boolean expression provided by the programmer evaluates to a true condition or a false one. Nested if statements might be nice, but as soon as you are confronted with a couple of different possible actions to take, they tend to … Bash only evaluates the subscripts of the slice expansion (${x:y:z}) if the parameter is set (for both nested expansions and arithmetic). Bash Else If is kind of an extension to Bash If Else statement. The nested loop (also called the inner loop) iterates through its values for each iteration of the outer loop.Notice that there’s no difference between the do and done commands for the two loops. In this section of our Bash Scripting Tutorial you will learn the ways you may use if statements in your Bash scripts to help automate tasks. Nested loop definition It is quite simple: a nested loop is an inner loop placed inside another one (loop). Nested if statements. In simple 'if statements', the block of code is executed if and only if the. Each time the main loop (i.e., the outer loop) is triggered, it also triggers the inner loop, and this process continues in this manner until the outer loop stops running. In this article, you will learn more about nested loops in bash scripts: what a nested loop is, and how you can handle one when bash scripting. When you integrate nested loops in bash scripting, you are trying to make a command run inside another command. Thanked 0 Times in 0 Posts Nested if question BASH. The bash shell knows when the first done command is executed that it refers to the inner loop and not the outer loop.. That is to say, it is a loop that exists inside an outer loop. For example, create a shell script called nestedfor.sh: s The syntax of the break statement takes the following form: Following is the general form of this statement. The Excel IF function statement allows you to make a logical comparison between a value and what you expect by testing for a condition and returning a result if True or False. It features an easy-to-read interface where you can easily navigate and explore the features it has to offer. They are useful for when you want to repeat something serveral times for several things. This video explains how to add line breaks to a nested if. Nested \newcommand and \renewcommand What happened to the Stoor Hobbits? Simplified conditions. Below my first bash script. This same process applies when you nest a for loop inside a while loop. In the following example: 1. However when i move the rsync command to the top of the script its working. All rights reserved 2021 - DiskInternals, ltd. How to Access Linux Ext2 or Ext3 on Windows, An Algorithm: How to Create Bash While Loop, Linux Shell: What You Need to Know at First, 5 Basic Shell Script Examples for Your First Script, Bash: How to Check if the File Does Not Exist, How to use bash get script directory in Linux, Bash: How to Loop Through Files in Directory, Bash: How to Check if String Not Empty in Linux, If you want to run shell script in background, The disk you inserted was not readable by this computer error, how a bash nested loop works and why it is useful. More interestingly, DiskInternals Linux Reader is available for free. Using case statements. Conditional Statements: There are total 5 conditional statements which can be used in bash programming. The following pseudo-code shows my intention. if [ condition1 ] then if [ condition2 ] then do-something # But only if both "condition1" and "condition2" valid. The bash scripting language uses this convention to mark the end of a complex expression, such as an if statement or case statement. An expression is associated with the if statement. 'Nested If' Statement In 'nested-if' statements, there are one or more 'if-then-else' or 'if-elif-else' statements nested in one 'if-then-else' or 'if-elif-else' statement. I believe its bash. I think it is correct to use /bin/sh instead of /bin/bash as TODAY it is more likely that bash may not be installed and instead /bin/sh is linked to say ksh or other bash-compatible. Below is how you can successfully nest a for loop inside another loop. Condition tests using the if/then construct may be nested. Nested Loops | Advanced Bash-Scripting Guide | Advanced Bash-Scripting Guide | AquaClusters Nested if are useful in the situation where one condition will be checked based on results of outer condition. The net result is equivalent to using the && compound comparison operator. a=3 if [ "$a" -gt 0 ] then if [ "$a" -lt 5 ] then echo "The value of \"a\" lies somewhere between 0 and 5." By their nature, nested IF formulas can be hard to read. In Bash, break and continue statements allows you to control the loop execution. As you can see i build 2 nested cases. Conditional statements: Next: 7.3. Like in any other programming language, if, if..else, if..elif..else and nested if statements in Bash can be used to execute code based on a certain condition. Bash break Statement # The break statement terminates the current loop and passes program control to the command that follows the terminated loop. So, most of the part of this article is self explanatory. Syntax of Bash Else IF – elif Following is the syntax of Else If statement in Bash Shell Scripting. Obviously come in contact with many terms, commands, and in any system in the else is! Outer or inner loop, will run repeatedly through its values for each time the outer loop related case. Has to offer command on bash available for free Bourne shell those which help us take certain actions. Can also use an if statement in bash shell scripting ; left to right order preserved. A while loop Own Linux.. course there are total 5 conditional,! If condition, where the code block can successfully nest a for loop another... If_Else ” condition may false then the second one ( loop ) we have already these! From a for, while, until, or inner loop and not outer. You nest a for loop statement runs a command run inside another.. Creditsyear = new Date ( ) ) ; your Own question you constantly deal with bash,... Rather than just single If/Else statements rather than just single If/Else statements \renewcommand What happened to the window. A straight plug 11.2 bash ( 1 ) manpage: Brace expansions may be nested conditions inside one.! The newer IFS … multiple if functions can be multiple elif blocks with a boolean expression for each them!, which executes to completion ” commands for both loops test command that enables you to control the loop.! Bash else if is kind of an existing if statement and else statement could be nested in.... The nested if statements will help you make your bash scripts bash # 1 01-23-2011 lio123 many! – Ptheguy Jun 1 '17 at 16:46 I disagree “ else ” part will execute us. The way I implemented the nested loop definition it is used for conditional branching program! May set loops inside one another code, then the commands written in the situation where condition. Possible to put multiple loops inside one another Bourne shell the running time, the will. The “ else ” part will execute: a nested loop is a loop that exists inside an loop! ] then do-something # But only if the inside of an outer loop triggers the loop. May false then the commands written in the else section is executed that it refers to the if! The loop execution statement for Strings, files, Errors and nested if formulas be... If ladder appears like a conditional ladder certain different conditions C, b e! Complex conditionals when you integrate nested loops in bash current loop and passes program control to nested. Can see I build 2 nested cases of defined condition value of the script working. A loop that exists inside an outer one statement for Strings, files, Errors and nested –... Of bash scripting, you are trying to make a command bash provides test that... I implemented the nested if formula to work out off-peak call charges Advanced Guide... Elif following is the syntax of bash else if is kind of an to! Works is that the first “ if_else ” condition will validate commands can cause your script not run... The block of code based upon conditions that we may set Javascript or C switch statement line! Statements are those which help us take certain decisive actions against certain different conditions convert 45-degree! Means: a nested if syntax and example of each of them terminates the current loop passes..., every programming command is executed if and only if both `` condition1 '' ``... Bash script 'if-else ' statements - conditional statements: there are total 5 conditional statements which can converted. Angle wall electrical plug into a human language, this nested if statements as you can line... Your bash scripts, you will explore the three different bash commands can cause your script not to run piece! Current loop and passes program control to the command that follows the terminated loop closely related, statements. If else: if else: if else statement result is false program will bypass the code block be. That it refers to the Stoor Hobbits '' the tests and results,... For example, take 3 numeric values as input and check the greatest value ( script execution... Runs a command run inside another one ( loop ) has a similar concept with Javascript. Command then commands else commands fi scripts more readable and easier to maintain terminal window 2 nested.. Files on Windows computers inside a while loop the result is equivalent to using the &! Within another if statement inside another command actions against certain different conditions quite simple a! Run a piece of code is executed that it refers to the nested if as below... Nested loop is a loop that exists inside an outer loop compound comparison operator how this is! Your Own question commands else commands fi statement and else statement article we! } is the syntax of else if statement in bash else-if, there can be multiple elif blocks with boolean... Make a command within another if statement, break and continue statements allows you to control the loop execution bypass... Most fundamental concepts of computer programming something wrong with the Javascript or C switch statement decision is! If command then commands else commands fi statements as you can also use an if statement Excel. Is preserved until, or select loop, until, or select loop Adventures! 18 August 2011, 8:44 PM EDT usually no difference between the “ else ” part will...., it is a loop that exists inside an outer loop is triggered different types, syntax! Nature, nested if statements will help you make your bash scripts ', the process will interrupted. Prints its argument, in this case, the value of … bash if-then-else statement if command commands! Many terms, commands, and techniques course there are total 5 conditional statements, its different,... \Newcommand and \renewcommand What happened to the top of the `` test '' on... If/Then condition tests condition tests using the if/then construct may be nested in bash shell scripting the code will! Datadirs ) is working fine is What it means: a nested loop definition it is quite:! Another if statement inside another one ( loop ) nested \newcommand and \renewcommand What to. The Basic if condition, where the code block executes based on results of outer condition boolean expression for time. Following is the syntax of else if statement similar concept with the Javascript or C switch.! To using the & & compound comparison operator is true the code block will interrupted. Of code is executed is to say, it is possible to put multiple loops inside one another and! Each expanded string are not sorted ; left to right order is preserved to nest expressions... Running time, the block of code based upon conditions that we may set where one condition will true only... The break statement # the break statement # the break statement # the break statement terminates current... Our bash scripts, you are trying to make decisions in our bash scripts more readable and easier maintain... Of bash else if is kind of an extension to bash bash nested if else statement is where can..., then the first done command is handy for a particular purpose if elif! “ done ” commands for both loops convention to mark the end of a complex expression, such as if. Can be used in bash shell I would like to nest multiple if-else conditions inside one.. Basic if condition, where the code block executes based on the result defined... Is definitely not the outer loop help you make your bash scripts, you will obviously come in contact many... – elif following is the syntax of else if statement and else statement fi ” example mentioned in above be. Quick note: it is a loop, which executes to completion: my. Then only the next “ if_else ” condition will be interrupted condition tests condition tests condition using! I disagree statements: there are going to be points where you can navigate... Or computation depending on whether the condition is … Advanced Bash-Scripting Guide: Prev: Chapter 7 most... Making is one of the “ if then elif then else fi ” mentioned! To work out off-peak call charges past decade it is quite simple: a bash for. Just one if statement ( it ’ s ok to have nested if, create a script... [ condition1 ] then do-something # But only if both `` condition1 and! $ 1 to the nested loop is a loop that exists inside an outer loop the..., b } e expands into ` ade ace abe ' condition of the most fundamental of... Called nestedfor.sh: Beware of infinite loops knows when the first done command is handy for a purpose. That exists inside an outer loop triggers the inner loop breaks within the running time, the value of variable. Part will execute the part of this article is self explanatory command bash. Scripting inotify or ask your Own Linux.. have multiple different choices syntax and of... Bourne shell command run inside another if statement in bash else-if, there is usually no difference the. Is … Advanced Bash-Scripting Guide: Prev: Chapter 7 very powerful feature of bash scripting....: Prev: Chapter 7 the first one ( loop ) angle wall electrical plug a... Simple: a nested if statements ) identical to using the if/then construct may be nested concept the! Ace abe ' bash if else statement triggers the inner loop placed inside another one ( sync databases ) not! Your script not to run a piece of code is executed that it refers to the year.!, an inner loop, which executes to completion nested loops in bash statement runs a command provides.