In bash, you can use ${!variable}
to use variable variables.
foo="something"
bar="foo"
echo "${!bar}"
# something
More Related Contents:
- Dynamic variable names in Bash
- Expansion of variables inside single quotes in a command in Bash
- Capturing multiple line output into a Bash variable
- Brace expansion with variable? [duplicate]
- How to store standard error in a variable
- What is the meaning of the ${0##…} syntax with variable, braces and hash character in bash?
- Using variables inside a bash heredoc
- Length of string in bash
- How to remove a newline from a string in Bash
- What is the difference between “$@” and “$*” in Bash? [duplicate]
- Variable containing multiple args with quotes in Bash
- Bash script compare two date variables [duplicate]
- What is the difference between ${var}, “$var”, and “${var}” in the Bash shell?
- What is the exact meaning of IFS=$’\n’?
- Parsing variables from config file in Bash
- How can I reference a file for variables using Bash?
- How to list variables declared in script in bash?
- Bash variables with spaces
- Is it possible to build variable names from other variables in bash? [duplicate]
- Bash indirect variable referencing
- How to modify a global variable within a function in bash?
- bash background process modify global variable
- Bash script store command output into variable
- osascript using bash variable with a space
- sed replace with variable with multiple lines [duplicate]
- Expand variables in sed
- bash piping prevents global variable assignment
- Left side of pipe is the subshell?
- Using a variable’s value as password for scp, ssh etc. instead of prompting for user input every time
- Loop over array, preventing wildcard expansion (*)