mirror of
https://github.com/dylanaraps/pure-bash-bible.git
synced 2025-12-17 07:54:19 +01:00
docs: update
This commit is contained in:
10
README.md
10
README.md
@@ -1101,8 +1101,11 @@ Alternative to the `basename` command.
|
|||||||
```sh
|
```sh
|
||||||
basename() {
|
basename() {
|
||||||
# Usage: basename "path"
|
# Usage: basename "path"
|
||||||
: "${1%/}"
|
dir=${1%${1##*[!/]}}
|
||||||
printf '%s\n' "${_##*/}"
|
dir=${dir##*/}
|
||||||
|
dir=${dir%"$2"}
|
||||||
|
|
||||||
|
printf '%s\n' "${dir:-/}"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -1112,6 +1115,9 @@ basename() {
|
|||||||
$ basename ~/Pictures/Wallpapers/1.jpg
|
$ basename ~/Pictures/Wallpapers/1.jpg
|
||||||
1.jpg
|
1.jpg
|
||||||
|
|
||||||
|
$ basename ~/Pictures/Wallpapers/1.jpg .jpg
|
||||||
|
1
|
||||||
|
|
||||||
$ basename ~/Pictures/Downloads/
|
$ basename ~/Pictures/Downloads/
|
||||||
Downloads
|
Downloads
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -40,8 +40,11 @@ Alternative to the `basename` command.
|
|||||||
```sh
|
```sh
|
||||||
basename() {
|
basename() {
|
||||||
# Usage: basename "path"
|
# Usage: basename "path"
|
||||||
: "${1%/}"
|
dir=${1%${1##*[!/]}}
|
||||||
printf '%s\n' "${_##*/}"
|
dir=${dir##*/}
|
||||||
|
dir=${dir%"$2"}
|
||||||
|
|
||||||
|
printf '%s\n' "${dir:-/}"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -51,6 +54,9 @@ basename() {
|
|||||||
$ basename ~/Pictures/Wallpapers/1.jpg
|
$ basename ~/Pictures/Wallpapers/1.jpg
|
||||||
1.jpg
|
1.jpg
|
||||||
|
|
||||||
|
$ basename ~/Pictures/Wallpapers/1.jpg .jpg
|
||||||
|
1
|
||||||
|
|
||||||
$ basename ~/Pictures/Downloads/
|
$ basename ~/Pictures/Downloads/
|
||||||
Downloads
|
Downloads
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user