#!/bin/bash
for i in 1 2 3 4
do
# {
# local i ##gives error local: can only be used in a function
for i in 1 2 3
do
echo "inner loop ----- $i"
(( i++ ))
done
# }
echo $i
done
Raus :
inner loop ----- 1
inner loop ----- 2
inner loop ----- 3
4
inner loop ----- 1
inner loop ----- 2
inner loop ----- 3
4
inner loop ----- 1
inner loop ----- 2
inner loop ----- 3
4
inner loop ----- 1
inner loop ----- 2
inner loop ----- 3
4
Ist es möglich, die Variable innerhalb der for-Schleife lokal zu verschachteln?