Adds Indirection and prefix name expansion (#2102)
This commit is contained in:
parent
c7d50cdbe1
commit
7317522a8c
20
bash.md
20
bash.md
|
@ -173,7 +173,7 @@ echo "${str/foo/bar}" # /path/to/bar.cpp
|
|||
|
||||
```bash
|
||||
str="Hello world"
|
||||
echo "${str:6:5}" # "world"
|
||||
echo "${str:6:5}" # "world"
|
||||
echo "${str: -5:5}" # "world"
|
||||
```
|
||||
|
||||
|
@ -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 |
|
||||
|
|
Loading…
Reference in New Issue