Added loops
This commit is contained in:
@@ -596,10 +596,17 @@ done
|
||||
## Loop over an array with an index.
|
||||
|
||||
```shell
|
||||
arr=(apples oranges tomatoes)
|
||||
|
||||
# Elements and index.
|
||||
for i in "${!arr[@]}"; do
|
||||
printf '%s\n' "${arr[$i]}"
|
||||
done
|
||||
|
||||
# Alternative method.
|
||||
for ((i=0;i<${#arr[@]};i++)); do
|
||||
printf '%s\n' "${arr[$i]}"
|
||||
done
|
||||
```
|
||||
|
||||
## Loop over the contents of a file.
|
||||
|
||||
Reference in New Issue
Block a user