1

In bash how can I use a variable's value to reference another variable?

e.g. my best attempt so far (which is the same as say -v es):

learning="es"
es="Jorge"
say -v $learning "Hola, me llamo Jorge"

How do I make it equivalent to say -v Jorge?


EDIT:

This has been closed as a duplicate, but I do not find the "duplicate" question useful at all. The answers there show how to set variables. I want to know how I can use them.

3
  • consider using associative arrays instead… Commented Dec 29, 2016 at 9:05
  • @gniourf_gniourf i didn't know bash had those. sounds like that would be a much better solution, rather than what I have atm: a whole file with a list of variable declarations xD Commented Dec 29, 2016 at 9:07
  • The solution is say -v "${!learning}" Commented Dec 29, 2016 at 15:04

0