Question: I have an unknown number of variable names with the pattern rundate\*. For example, `rundate=180618 && rundate2=180820`. I know from [here](https://stackoverflow.com/questions/511694/get-list-of-variables-whose-name-matches-a-certain-pattern) that I can send multiple variable names to a third variable: `alld=(`echo "${!rundate*}"`)` and while attempting to solve my problem, I figured out how to send multiple variable indices to a third variable: `alld_indices=(`echo "${!alld[@]}"`)`. But, how do I send multiple values to my third variable: `alld_values` such that `echo ${alld_values[@]}` gives `180618 180820`. I know from [here](https://stackoverflow.com/questions/1921279/how-to-get-a-variable-value-if-variable-name-is-stored-as-string) how I can get the first value: `firstd_value=(`echo "${!alld}"`)`. I suspect, I've seen the answer already in my searching but did not realize it. Happy to delete my question if that is the case. Thanks!

Answer: 
```sh
#!/usr/bin/env bash

# set up some test data
rundate="180618"
rundate1="180820"
rundate2="Values With Spaces Work Too"

# If we know all values are numeric, we can use a regular indexed array
# otherwise, the below would need to be ''declare -A alld=( )''
alld=( )                       # initialize an array
for v in "${!rundate@}"; do    # using @ instead of * avoids IFS-related bugs
  alld[${v#rundate}]=${!v}     # populate the array, using varname w/o prefix as key
done

# print our results
printf 'Full array definition:\n   '
declare -p alld                 # emits code that, if run, will redefine the array
echo; echo "Indexes only:"
printf ' - %s\n' "${!alld[@]}"  # "${!varname[@]}" expands to the list of keys
echo; echo "Values only:"
printf ' - %s\n' "${alld[@]}"   # "${varname[@]}" expands to the list of values

```

...properly emits as output:

```none
Full array definition:
   declare -a alld=([0]="180618" [1]="180820" [2]="Values With Spaces Work Too")

Indexes only:
 - 0
 - 1
 - 2

Values only:
 - 180618
 - 180820
 - Values With Spaces Work Too

```

...as you can see running at <https://ideone.com/yjSD1J>
`eval` in a loop will do it.

```
$: for v in ${!rundate*}
>  do eval "alld_values+=( \$$v )"
>  done
$: echo "${alld_values[@]}"
180618 180820

```

or

```
$: eval "alld_values=( $( sed 's/ / $/g' <<< " ${!rundate*}" ) )"

```

or 

```
$: echo "alld_values=( $( sed 's/ / $/g' <<< " ${!rundate*}" ) )" > tmp && . tmp

```