Skip to content

Instantly share code, notes, and snippets.

@shkitch
Last active February 17, 2017 08:26
Show Gist options
  • Save shkitch/1c2e1ee37d18547c37dad767ac31c78e to your computer and use it in GitHub Desktop.
Save shkitch/1c2e1ee37d18547c37dad767ac31c78e to your computer and use it in GitHub Desktop.
A demonstration of bash arrays.
#!/bin/bash
#
# A demonstration of bash arrays. See the secions titled "Arrays" and
# "Parameter Expansion" in the bash man page for details.
#
declare -A array;
array[a]="1";
array[b]="2";
array[c]="3";
array[d]="4";
for key in ${!array[@]}; do
value=${array[$key]}
echo "This is an array key/value pair: '$key' -> '$value'"
done
# vim: set ts=4 sw=0 et cc=80:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment