Dir structure:
./dir1
./dir2
array=()
for dir in */
do
dir=${dir%*/}
( echo "$dir" )
array+=("$dir")
done
echo "${array[@]}"
Outputs:
dir1
dir2
dir1 dir2
Loop over array in bash
for i in "${array[@]}"
do
echo "$i"
done
Outputs:
dir1
dir2