1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2025-10-14 22:48:31 +02:00

adding an alternate shorter way that does not depend on the basename (#2191)

This commit is contained in:
cubangeorge 2025-08-23 18:30:43 -04:00 committed by GitHub
parent 1f681bd293
commit 01ee3a82c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -175,6 +175,7 @@ echo "${str: -5:5}" # "world"
src="/path/to/foo.cpp"
base=${src##*/} #=> "foo.cpp" (basepath)
dir=${src%$base} #=> "/path/to/" (dirpath)
dir=${src%/*} #=> "/path/to" (dirpath)
```
### Prefix name expansion