About 744,000 results
Open links in new tab
  1. 9 Examples of for Loops in Linux Bash Scripts - How-To Geek

    Oct 30, 2023 · For each loop, the iterator takes on the value of the next number, string, or whatever data type the loop is iterating over. This allows the loop to work with the values of …

  2. unix - Shell script "for" loop syntax - Stack Overflow

    If you don’t have to be totally POSIX, you can use the arithmetic for loop: max=10 for (( i=0; i < max; i++ )); do echo "output: $i"; done Or use jot (1) on BSD systems:

  3. Looping Statements | Shell Script - GeeksforGeeks

    Jan 3, 2024 · done: Marks the end of the loop. `for` statement in Shell Script in Linux. The for loop operates on lists of items. It repeats a set of commands for every item in a list. Here var is the name of a variable and word1 to wordN are sequences of characters separated by …

  4. Bash Scripting - For Loop - GeeksforGeeks

    Sep 15, 2023 · To execute a for loop we can write the following syntax: echo $n. In the first iteration, n takes the value “a”, and the script prints “a”. In the second iteration, n takes the value “b”, and the script prints “b”. In the third iteration, n takes the value “c”, and the script prints “c”.

  5. How do I write a 'for' loop in Bash? - Stack Overflow

    Sep 8, 2008 · for: for NAME [in WORDS ... ;] do COMMANDS; done The `for' loop executes a sequence of commands for each member in a list of items. If `in WORDS ...;' is not present, then `in "$@"' is assumed. For each element in WORDS, NAME is set to that element, and the COMMANDS are executed.

  6. Bash For Loop Examples - nixCraft

    Jan 31, 2025 · What is a Bash for loop? A bash for loop is a bash programming language statement which allows code to be repeatedly executed. A for loop is classified as an iteration statement i.e. it is the repetition of a process within a bash script. For example, you can run UNIX command or task 5 times or read and process list of files using a for loop.

  7. 10 Common Bash “for” Loop Examples [Basic to Intermediate]

    Mar 17, 2024 · 10 Common Bash scripting examples of using the "for" loop to generate patterns, different mathematical sequences, passwords, etc.

  8. How to Use Bash “for” Loop with “seq” Command [10 Examples]

    Mar 17, 2024 · Within the realm of Bash scripting, combining the “for” loop with the “seq” command unlocks robust automation and streamlined numerical manipulation. The “for” loop serves as the iterative engine, powering the execution of tasks across a …

  9. Using for loops and while loops in a shell script - The Shell Scripting ...

    As a result, we have for and while loops in the Bourne shell. This is somewhat fewer features than other languages, but nobody claimed that shell programming has the power of C. For Loops. for loops iterate through a set of values until the list is exhausted:

  10. Using For, While and Until Loops in Bash [Beginner's Guide]

    For loops are one of three different types of loop structures that you can use in bash. There are two different styles for writing a for loop. If you are familiar with a C or C++ like programming language, then you will recognize the following for loop syntax:

Refresh