docs: update

This commit is contained in:
Dylan Araps 2018-06-14 14:32:13 +10:00
parent eb51cfcdb3
commit c0c62478fc
1 changed files with 21 additions and 1 deletions

View File

@ -36,6 +36,8 @@ scripts and not full blown utilities.
* [Trim quotes from a string.](#trim-quotes-from-a-string)
* [Strip characters from start of string.](#strip-characters-from-start-of-string)
* [Strip characters from end of string.](#strip-characters-from-end-of-string)
* [Variables](#variables)
* [Assign and access a variable using a variable.](#assign-and-access-a-variable-using-a-variable)
* [Arrays](#arrays)
* [Reverse an array.](#reverse-an-array)
* [Remove duplicate array elements.](#remove-duplicate-array-elements)
@ -77,8 +79,8 @@ scripts and not full blown utilities.
<!-- vim-markdown-toc -->
## Strings
## Strings
### Trim white-space from string.
@ -156,6 +158,24 @@ rstrip() {
}
```
## Variables
### Assign and access a variable using a variable.
```sh
# 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'"
```
## Arrays
### Reverse an array.