Skip to content

Commit

Permalink
Adds Indirection and prefix name expansion (#2102)
Browse files Browse the repository at this point in the history
  • Loading branch information
caruccio authored Feb 14, 2024
1 parent c7d50cd commit 7317522
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```

Expand All @@ -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 |
Expand Down

0 comments on commit 7317522

Please sign in to comment.