array Demos
This commit is contained in:
10
arrays/associative_array.sh
Executable file
10
arrays/associative_array.sh
Executable 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[@]}")
|
Reference in New Issue
Block a user