This commit is contained in:
2018-10-01 22:05:59 -05:00
parent 3d5fda2e52
commit fb718da5a1
2 changed files with 18 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
#!/bin/bash
# Wrapper script for install, for easier execution via URL.
if [ "$EUID" -ne 0 ]; then PREFIX='sudo'; else PREFIX=''; fi
if type apt &>/dev/null; then

17
test.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
declare -A array
array[x1,y1]=100
array[x1,y2]=200
array[x2,y1]=300
array[x2,y2]=400
#alternative 1, extract all the main keys with sort
for key in $(printf '%s\n' "${!array[@]}" | sed 's/,.*//' | sort -u); do
#alternative 2, keeping track of the main keys
keys=(x1 x2)
for key in "${keys[@]}"; do
#the loop contents are the same
echo "$key : y1 = ${array[$key,y1]}"
echo "$key : y2 = ${array[$key,y2]}"
done