docs: update

This commit is contained in:
Dylan Araps 2019-09-19 19:58:29 +03:00
parent 11ab391065
commit 9d00d2413e
2 changed files with 16 additions and 4 deletions

View File

@ -1101,8 +1101,11 @@ Alternative to the `basename` command.
```sh
basename() {
# Usage: basename "path"
: "${1%/}"
printf '%s\n' "${_##*/}"
dir=${1%${1##*[!/]}}
dir=${dir##*/}
dir=${dir%"$2"}
printf '%s\n' "${dir:-/}"
}
```
@ -1112,6 +1115,9 @@ basename() {
$ basename ~/Pictures/Wallpapers/1.jpg
1.jpg
$ basename ~/Pictures/Wallpapers/1.jpg .jpg
1
$ basename ~/Pictures/Downloads/
Downloads
```

View File

@ -40,8 +40,11 @@ Alternative to the `basename` command.
```sh
basename() {
# Usage: basename "path"
: "${1%/}"
printf '%s\n' "${_##*/}"
dir=${1%${1##*[!/]}}
dir=${dir##*/}
dir=${dir%"$2"}
printf '%s\n' "${dir:-/}"
}
```
@ -51,6 +54,9 @@ basename() {
$ basename ~/Pictures/Wallpapers/1.jpg
1.jpg
$ basename ~/Pictures/Wallpapers/1.jpg .jpg
1
$ basename ~/Pictures/Downloads/
Downloads
```