Posts

Showing posts with the label statement

Break and Continue statement in shell script

Break and Continue statement in shell script DESCRIPTION: All statement inside the loop executed as long as some condition are true. If break placed inside the loop, when loop reach the break statement it will terminated out from the loop. If continue placed inside the loop, when loop reach the continue statement it will not execute next lines of the loop and it will go to the next iteration. script for break: #!/bin/bash x=0 while [ $x -le 5 ] do     echo "Before break : $x"     x=`expr $x + 1`     break     echo "After breakn : $x" done echo "While loop finished" output: Before break : 0 While loop finished script for continue: #!/bin/bash x=0 while [ $x -le 5 ] do     echo "Before continue : $x"     x=`expr $x + 1`     continue     echo "After continue : $x" done echo "While loop finished"      output Before continue : 0 Before continue : 1 Befor...