Skip to content

Instantly share code, notes, and snippets.

@vain
Created May 18, 2012 16:04
Show Gist options
  • Save vain/2726048 to your computer and use it in GitHub Desktop.
Save vain/2726048 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Index based array -- both "hello" and "bar" evaluate to 0:
indarr["hello"]="world!"
indarr["bar"]="baz"
echo "Contents of indarr:"
for k in "${!indarr[@]}"
do
echo "<$k>: <${indarr[$k]}>"
done
# String-associative array:
declare -A strarr
strarr["hello"]="world!"
strarr["bar"]="baz"
echo "Contents of strarr:"
for k in "${!strarr[@]}"
do
echo "<$k>: <${strarr[$k]}>"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment