mirror of
https://github.com/onkelbeh/cheatsheets.git
synced 2026-08-15 21:44:51 +02:00
Adds Indirection and prefix name expansion (#2102)
This commit is contained in:
18
bash.md
18
bash.md
@@ -183,6 +183,24 @@ base=${src##*/} #=> "foo.cpp" (basepath)
|
||||
dir=${src%$base} #=> "/path/to/" (dirpath)
|
||||
```
|
||||
|
||||
### Prefix name expansion
|
||||
|
||||
```bash
|
||||
prefix_a=one
|
||||
prefix_b=two
|
||||
echo ${!prefix_*} # all variables names starting with `prefix_`
|
||||
prefix_a prefix_b
|
||||
```
|
||||
|
||||
### Indirection
|
||||
|
||||
```bash
|
||||
name=joe
|
||||
pointer=name
|
||||
echo ${!pointer}
|
||||
joe
|
||||
```
|
||||
|
||||
### Substitution
|
||||
|
||||
| Code | Description |
|
||||
|
||||
Reference in New Issue
Block a user