docs: update
This commit is contained in:
16
README.md
16
README.md
@@ -19,6 +19,7 @@ align="center">A collection of pure POSIX sh alternatives to external processes.
|
|||||||
* [Split a string on a delimiter](#split-a-string-on-a-delimiter)
|
* [Split a string on a delimiter](#split-a-string-on-a-delimiter)
|
||||||
* [Trim quotes from a string](#trim-quotes-from-a-string)
|
* [Trim quotes from a string](#trim-quotes-from-a-string)
|
||||||
* [FILES](#files)
|
* [FILES](#files)
|
||||||
|
* [Parsing a `key=val` file.](#parsing-a-keyval-file)
|
||||||
* [Get the first N lines of a file](#get-the-first-n-lines-of-a-file)
|
* [Get the first N lines of a file](#get-the-first-n-lines-of-a-file)
|
||||||
* [Get the number of lines in a file](#get-the-number-of-lines-in-a-file)
|
* [Get the number of lines in a file](#get-the-number-of-lines-in-a-file)
|
||||||
* [Count files or directories in directory](#count-files-or-directories-in-directory)
|
* [Count files or directories in directory](#count-files-or-directories-in-directory)
|
||||||
@@ -331,6 +332,21 @@ Hello, World
|
|||||||
|
|
||||||
# FILES
|
# FILES
|
||||||
|
|
||||||
|
## Parsing a `key=val` file.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# Setting 'IFS' tells 'read' where to split the string.
|
||||||
|
while IFS='=' read -r key val; do
|
||||||
|
# Skip over lines containing comments.
|
||||||
|
# (Lines starting with '#').
|
||||||
|
[ "${key##\#*}" ] || continue
|
||||||
|
|
||||||
|
# '$key' stores the key.
|
||||||
|
# '$val' stores the value.
|
||||||
|
printf '%s: %s\n' "$key" "$val"
|
||||||
|
done < "file"
|
||||||
|
```
|
||||||
|
|
||||||
## Get the first N lines of a file
|
## Get the first N lines of a file
|
||||||
|
|
||||||
Alternative to the `head` command.
|
Alternative to the `head` command.
|
||||||
|
|||||||
Reference in New Issue
Block a user