1
0
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:
Mateus Caruccio
2024-02-14 20:40:36 +00:00
committed by GitHub
parent c7d50cdbe1
commit 7317522a8c

18
bash.md
View File

@@ -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 |