mirror of
https://github.com/dylanaraps/pure-sh-bible
synced 2024-05-17 21:06:36 +02:00
docs: update
This commit is contained in:
parent
55bce36ca7
commit
0403a47f48
|
@ -477,15 +477,15 @@ $ lines ~/.bashrc
|
||||||
|
|
||||||
This works by passing the output of the glob to the function and then counting the number of arguments.
|
This works by passing the output of the glob to the function and then counting the number of arguments.
|
||||||
|
|
||||||
**CAVEAT:** When the glob does not match anything (empty directory or no matching files) it is not expanded and the function returns `1`.
|
|
||||||
|
|
||||||
**Example Function:**
|
**Example Function:**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
count() {
|
count() {
|
||||||
# Usage: count /path/to/dir/*
|
# Usage: count /path/to/dir/*
|
||||||
# count /path/to/dir/*/
|
# count /path/to/dir/*/
|
||||||
printf '%s\n' "$#"
|
[ -e "$1" ] \
|
||||||
|
&& printf '%s\n' "$#" \
|
||||||
|
|| printf '%s\n' 0
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue