You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
642 B
39 lines
642 B
#! /usr/bin/bash
|
|
|
|
# Array of numbers
|
|
fib=(0 1 2 3 5 8)
|
|
|
|
#Array of Strings
|
|
family=("Marge" "Homer" "Bart" "Lisa" "Maggie")
|
|
|
|
# Einfache for Schleife
|
|
|
|
for name in "${family[@]}"
|
|
do
|
|
echo "for: name=${name}"
|
|
done
|
|
echo "---"
|
|
# C-ähnliche Schleife im Index
|
|
len=${#family[@]}
|
|
|
|
for ((i=0;i < len; i++));do
|
|
echo "for-i: name=${family[i]},i= ${i}"
|
|
done
|
|
echo "---"
|
|
|
|
# while Schleife
|
|
counter=0
|
|
|
|
while [ ${counter} -lt ${len} ]; do
|
|
echo "while: name=${family[counter]},counter=${counter}"
|
|
((counter++))
|
|
done
|
|
echo "---"
|
|
|
|
# until Schleife
|
|
counter=0
|
|
|
|
until [ $counter -ge $len ]; do
|
|
echo "until: ${family[counter]}"
|
|
((counter++))
|
|
done
|
|
|