docs: update
This commit is contained in:
parent
26079b4aae
commit
2e841bb045
40
README.md
40
README.md
|
@ -25,6 +25,9 @@ list, send a pull request!
|
|||
* [Get the directory name of a file path.](#get-the-directory-name-of-a-file-path)
|
||||
* [Convert a hex color to RGB](#convert-a-hex-color-to-rgb)
|
||||
* [Convert an RGB color to hex.](#convert-an-rgb-color-to-hex)
|
||||
* [Trim quotes from a string.](#trim-quotes-from-a-string)
|
||||
* [Get the first N lines in a file.](#get-the-first-n-lines-in-a-file)
|
||||
* [Get the last N lines in a file.](#get-the-last-n-lines-in-a-file)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
|
@ -94,4 +97,41 @@ rgb_to_hex() {
|
|||
}
|
||||
```
|
||||
|
||||
## Trim quotes from a string.
|
||||
|
||||
```sh
|
||||
trim_quotes() {
|
||||
# Usage: trim_quotes "string"
|
||||
: "${1//\'}"
|
||||
printf "%s\\n" "${_//\"}"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Get the first N lines in a file.
|
||||
|
||||
Alternative to the `head` command.
|
||||
|
||||
**NOTE:** Requires `bash` 4+
|
||||
|
||||
```sh
|
||||
head() {
|
||||
# Usage: head "n" "file"
|
||||
mapfile -tn "$1" line < "$2"
|
||||
printf '%s\n' "${line[@]}"
|
||||
}
|
||||
```
|
||||
|
||||
## Get the last N lines in a file.
|
||||
|
||||
Alternative to the `tail` command.
|
||||
|
||||
**NOTE:** Requires `bash` 4+
|
||||
|
||||
```sh
|
||||
tail() {
|
||||
# Usage: tail "n" "file"
|
||||
mapfile -tn 0 line < "$2"
|
||||
printf '%s\n' "${line[@]: -$1}"
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue