Skip to content

Bash Scripting – For And While Loops With Examples

github logo ・1 min read  

In a previous post, we talked about how to write a bash script , and we saw how bash scripting is awesome. In this post, we will look at the for command, while command, and how to make loops to iterate over a series of values.

1 for Command
2 Iterating Over Simple Values
3 Iterating Over Complex Values
4 Command Substitution
5 The Field Separator
6 Iterating Over Directory Files
7 for Command C-Style
8 The while Command
9 Nesting Loops
10 Iterate Over File Content
11 Controlling the Loop
11.1 The break Command
11.2 The continue command
12 Redirecting the Loop Output
13 Useful Examples
13.1 Finding executables

Thanks in advance.

twitter logo DISCUSS
Classic DEV Post from Jul 30 '19

PublishTo.Dev: Scheduling article publishing on

macnux profile image