docs: update

This commit is contained in:
Dylan Araps
2019-09-19 11:30:09 +03:00
parent a020c7ade3
commit 67d9bf0668

View File

@@ -16,6 +16,7 @@ A collection of pure POSIX `sh` alternatives to external processes
* [Check if string ends with sub-string](#check-if-string-ends-with-sub-string)
* [FILES](#files)
* [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)
<!-- vim-markdown-toc -->
@@ -177,3 +178,30 @@ PS1='➜ '
$ head 1 ~/.bashrc
# Prompt
```
## Get the number of lines in a file
Alternative to `wc -l`.
**Example Function:**
```sh
lines() {
# Usage: lines "file"
while read -r _; do
lines=$((lines+1))
done < "$1"
printf '%s\n' "$lines"
}
```
**Example Usage:**
```shell
$ lines ~/.bashrc
48
$ lines_loop ~/.bashrc
48
```