DEV Community

macnux
macnux

Posted on

Bash Scripting – For And While Loops With Examples

In a previous post, we talked about how to write a bash script https://likegeeks.com/bash-script-easy-guide/ , 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

https://likegeeks.com/bash-scripting-step-step-part2/

Thanks in advance.

Top comments (0)