About 750,000 results
Open links in new tab
  1. Looping over arrays, printing both index and value

    Mar 19, 2017 · "${foo[@]}" takes the (array) variable foo and expands it as an array, maintaining the identity of its elements, i.e., not splitting them on whitespace. If foo=(x 'y z') , then f …

  2. How to Print an Array in Bash? [5 Cases] - LinuxSimply

    Apr 23, 2024 · Using loop is an effective technique to perform tasks requiring repetition such as printing the elements of an indexed or associative array in Bash. For instance, the for ((i=0; …

  3. Array Basics Shell Scripting | Set 2 (Using Loops)

    Apr 18, 2023 · In Bourne Shell there are two types of loops i.e for loop and while loop. To Print the Static Array in Bash 1. By Using while-loop $ {#arr [@]} is used to find the size of Array. …

  4. Bash Array – While Loop - Tutorial Kart

    To iterate over items of an array in Bash, we can use While loop. In the While loop start with index=0 and execute the loop until index is less than array length. During each iteration we …

  5. Introduction to Bash while Loop with Examples - Its Linux FOSS

    For example, let’s create a Bash script that has an array of 5 elements and print each element using the while loop. #!/bin/bash city=("Washington" "New_York" "Texas" "Chicago" "Austin") …

  6. 3 Ways to Iterate an Array in Bash - LinuxSimply

    Apr 17, 2024 · In this tutorial, you will learn in-depth about how to iterate through array in Bash using three loop-based (for, while, until) methods.

  7. Loop through an array of strings in Bash? - Stack Overflow

    Jan 16, 2012 · How you loop through an array, depends on the presence of new line characters. With new line characters separating the array elements, the array can be referred to as …

  8. Bash While Loop Examples - nixCraft

    Mar 12, 2024 · For example, run echo command 5 times or read text file line by line or evaluate the options passed on the command line for a script. The syntax is as follows: command1. …

  9. How to Print Array Elements in Shell Script | LabEx

    Learn how to print array elements in Shell script using for loops, echo commands, and while loops for effective scripting.

  10. Bash Scripting – While Loop - GeeksforGeeks

    Jan 2, 2022 · We can read a file with a while loop in BASH. By parsing certain parameters to the while loop condition, we can iterate over the file line by line or by other groups like characters …

  11. Some results have been removed
Refresh