array Demos

This commit is contained in:
2025-09-07 14:15:56 +02:00
parent 96f5040dfe
commit 0d67903acf
8 changed files with 137 additions and 0 deletions

10
arrays/associative_array.sh Executable file
View File

@@ -0,0 +1,10 @@
#! /usr/bin/bash
declare -A family
family=([father]="Homer" [mother]="Marge" [son]="Bart" [daughter]="Lisa" [baby]="Maggie")
echo "Iterating through associative array using while loop:"
while IFS= read -r key && IFS= read -r value <&3; do
echo "Key: $key, Value: $value"
done < <(printf '%s\n' "${!family[@]}") 3< <(printf '%s\n' "${family[@]}")