docs: update

This commit is contained in:
Dylan Araps
2018-06-13 13:42:29 +10:00
parent b9a2591b45
commit d5b19a5f2a

View File

@@ -37,6 +37,8 @@ scripts and not full blown utilities.
* [Change a string to lowercase.](#change-a-string-to-lowercase) * [Change a string to lowercase.](#change-a-string-to-lowercase)
* [Change a string to uppercase.](#change-a-string-to-uppercase) * [Change a string to uppercase.](#change-a-string-to-uppercase)
* [Trim quotes from a string.](#trim-quotes-from-a-string) * [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)
* [Arrays](#arrays) * [Arrays](#arrays)
* [Reverse an array.](#reverse-an-array) * [Reverse an array.](#reverse-an-array)
* [File Paths](#file-paths) * [File Paths](#file-paths)
@@ -189,6 +191,24 @@ trim_quotes() {
} }
``` ```
### Strip characters from start of string.
```sh
lstrip() {
# Usage: lstrip "string" "chars to remove"
printf '%s\n' "${1##$2}"
}
```
### Strip characters from end of string.
```sh
rstrip() {
# Usage: rstrip "string" "chars to remove"
printf '%s\n' "${1%%$2}"
}
```
## Arrays ## Arrays
### Reverse an array. ### Reverse an array.
@@ -228,8 +248,8 @@ Alternative to the `basename` command.
```sh ```sh
basename() { basename() {
# Usage: basename "path" # Usage: basename "path"
path="${1%/}" : "${1%/}"
printf '%s\n' "${path##*/}" printf '%s\n' "${_##*/}"
} }
``` ```