2025-07-24 22:27:13 -06:00
|
|
|
# {
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
> Multipurpose shell syntax.
|
|
|
|
|
> More information: <https://www.gnu.org/software/bash/manual/bash.html>.
|
|
|
|
|
|
|
|
|
|
- Isolate variable names:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`echo ${{{HOME}work}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Brace expand sequences:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`echo {{{1..3}}} {{{a..c}}}{{{dir1,dir2,dir3}}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Check if `variable` is set before returning text:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`echo ${{{variable:+variable is set and contains $variable}}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Set default values in case `variable` is unset:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`echo ${{{variable:-default}}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Return `variable` length in characters:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`echo ${{{#variable}}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Return a string slice:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`echo ${{{variable:3:7}}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Recursively expand a `variable`:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`echo ${{{!variable}}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Group command output together:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`{ {{command1; command2; ...}} } | {{another_command}}`
|