Looping in Bash
Basic Loops
In bash, looping can be done like so:
for i in **/*.md; do
# do something with i
doneThis lets us set get the value of every iteration, but we can’t access the index.
Looping with Index
Assuming we have an array of items, and we want to get the index of their items as well:
items=(10,20,30)
for i in ${!items[@]}; do
echo "Key: $i"
echo "Value: ${allThreads[$i]}"
doneCalculating Array Length
Array lengths can be calculated like so:
items=(10, 20, 30)
${#items[@]}