Last active
February 17, 2017 08:26
-
-
Save shkitch/1c2e1ee37d18547c37dad767ac31c78e to your computer and use it in GitHub Desktop.
A demonstration of bash arrays.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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