docs: update
This commit is contained in:
20
README.md
20
README.md
@@ -192,24 +192,14 @@ rstrip() {
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
_() {
|
_() {
|
||||||
# First Example.
|
hello_world="test"
|
||||||
|
|
||||||
|
# Create the variable name.
|
||||||
var1="world"
|
var1="world"
|
||||||
var2="hello_${var1}"
|
var2="hello_${var1}"
|
||||||
declare "${var2}=test_string"
|
|
||||||
|
# Print the value of the variable name stored in 'hello_$var1'.
|
||||||
printf '%s\n' "${!var2}"
|
printf '%s\n' "${!var2}"
|
||||||
|
|
||||||
|
|
||||||
# Second Example.
|
|
||||||
# Assign to a variable named after the
|
|
||||||
# value stored in '$var'.
|
|
||||||
var="test"
|
|
||||||
read -rp "input text: " "${var?}"
|
|
||||||
|
|
||||||
# Access the variable indirectly.
|
|
||||||
printf '%s\n' "set var \$$var to '${!var}'"
|
|
||||||
|
|
||||||
# Access the variable directly.
|
|
||||||
printf '%s\n' "set var \$$var to '$test'"
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user