NOTE

Assuming you’re already logged in

1. heredoc

1.1. Exercise

#!/bin/bash

var=$(cat <<EOF
declare -A array=(
  [1,0]="first name"
  [1,1]="second name"
  [2,0]="third name"
  [3,0]="foo bar"
  [test 1]="test bar"
  )
EOF
)

echo "$var"

cat <<'EOF'
  ----------------------------------------------------------
        for with "${!array[@]}"
  ----------------------------------------------------------
for i in "${!array[@]}"; do
        echo "$i => ${array[$i]}";
done

    "result: "
EOF

for i in "${!array[@]}"; do
        echo "$i => ${array[$i]}";
done

echo ""
echo ""

1.2. expansion

real_fc="barca"            # set real_fc
win="real_fc"              # $win is "real_fc"
echo "${!win}"             # we print the variable linked by $win's content