For Loop in Bash Script (Shell Scripting)
Tamizh Tech Tutorial For Loop in Bash Script (Shell Script) Shell Scripting Tutorial For Loop It is an example of looping statement and alternative for while loop It is used to execute group of statements based on the looping condition Bash supports several examples of for-loops. Some of them below Simple for loop Range based for loop C Style based for loop Infinite for loop. 1. Simple for loop (Data based for loop) Here the loop is based on the data or collection. The data can be the same type or different type. Syntax f or variable in data do # code done Where, variable is an user defined variable. Example 1 - Data based for loop Source Code echo "--------------------------------" echo -e "\t Data based For Loop" echo "--------------------------------" for i in 12 true "Hello" 34.55 do echo " $i" done Output 2. Range Based for loop Here the loop is based on the three attributes like start, stop and interval . These a...