mirror of
https://github.com/dylanaraps/pure-sh-bible
synced 2024-05-03 22:23:13 +02:00
Dynamic variable naming magic
This commit is contained in:
parent
70f410ebb2
commit
9bcd730b6f
|
@ -677,12 +677,12 @@ done
|
|||
|
||||
# VARIABLES
|
||||
|
||||
## Name a variable based on another variable
|
||||
## Name and access a variable based on another variable
|
||||
|
||||
```shell
|
||||
$ var="world"
|
||||
$ export "hello_$var=value"
|
||||
$ printf '%s\n' "$hello_world"
|
||||
$ eval "hello_$var=value"
|
||||
$ eval printf '%s\n' "\$hello_$var"
|
||||
value
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue