Added build files to turn the bible into a book
This commit is contained in:
@@ -1,68 +1,42 @@
|
||||
# Parameter Expansion
|
||||
# Brace Expansion
|
||||
|
||||
## Indirection
|
||||
## Ranges
|
||||
|
||||
| Parameter | What does it do? |
|
||||
| --------- | ---------------- |
|
||||
| `${!VAR}` | Access a variable based on the value of `VAR`. See: [link](#assign-and-access-a-variable-using-a-variable)
|
||||
| `${!VAR*}` | Expand to `IFS` separated list of variable names starting with `VAR`. |
|
||||
| `${!VAR@}` | Expand to `IFS` separated list of variable names starting with `VAR`. |
|
||||
```shell
|
||||
# Syntax: {<START>..<END>}
|
||||
|
||||
# Print numbers 1-100.
|
||||
echo {1..100}
|
||||
|
||||
## Replacement
|
||||
# Print range of floats.
|
||||
echo 1.{1..9}
|
||||
|
||||
| Parameter | What does it do? |
|
||||
| --------- | ---------------- |
|
||||
| `${VAR#PATTERN}` | Remove shortest match of pattern from start of string. |
|
||||
| `${VAR##PATTERN}` | Remove longest match of pattern from start of string. |
|
||||
| `${VAR%PATTERN}` | Remove shortest match of pattern from end of string. |
|
||||
| `${VAR%%PATTERN}` | Remove longest match of pattern from end of string. |
|
||||
| `${VAR/PATTERN/REPLACE}` | Replace first match with string.
|
||||
| `${VAR//PATTERN/REPLACE}` | Replace all matches with string.
|
||||
| `${VAR/PATTERN}` | Remove first match.
|
||||
| `${VAR//PATTERN}` | Remove all matches.
|
||||
# Print chars a-z.
|
||||
echo {a..z}
|
||||
echo {A..Z}
|
||||
|
||||
## Length
|
||||
# Nesting.
|
||||
echo {A..Z}{0..9}
|
||||
|
||||
| Parameter | What does it do? |
|
||||
| --------- | ---------------- |
|
||||
| `${#VAR}` | Length of var in characters.
|
||||
| `${#ARR[@]}` | Length of array in elements.
|
||||
# Print zero-padded numbers.
|
||||
# CAVEAT: bash 4+
|
||||
echo {01..100}
|
||||
|
||||
## Expansion
|
||||
# Change increment amount.
|
||||
# Syntax: {<START>..<END>..<INCREMENT>}
|
||||
# CAVEAT: bash 4+
|
||||
echo {1..10..2} # Increment by 2.
|
||||
```
|
||||
|
||||
| Parameter | What does it do? |
|
||||
| --------- | ---------------- |
|
||||
| `${VAR:OFFSET}` | Remove first `N` chars from variable.
|
||||
| `${VAR:OFFSET:LENGTH}` | Get substring from `N` character to `N` character. <br> (`${VAR:10:10}`: Get sub-string from char `10` to char `20`)
|
||||
| `${VAR:: OFFSET}` | Get first `N` chars from variable.
|
||||
| `${VAR:: -OFFSET}` | Remove last `N` chars from variable.
|
||||
| `${VAR: -OFFSET}` | Get last `N` chars from variable.
|
||||
| `${VAR:OFFSET:-OFFSET}` | Cut first `N` chars and last `N` chars. | `bash 4.2+` |
|
||||
## String Lists
|
||||
|
||||
## Case Modification
|
||||
|
||||
| Parameter | What does it do? | CAVEAT |
|
||||
| --------- | ---------------- | ------ |
|
||||
| `${VAR^}` | Uppercase first character. | `bash 4+` |
|
||||
| `${VAR^^}` | Uppercase all characters. | `bash 4+` |
|
||||
| `${VAR,}` | Lowercase first character. | `bash 4+` |
|
||||
| `${VAR,,}` | Lowercase all characters. | `bash 4+` |
|
||||
|
||||
|
||||
## Default Value
|
||||
|
||||
| Parameter | What does it do? |
|
||||
| --------- | ---------------- |
|
||||
| `${VAR:-STRING}` | If `VAR` is empty or unset, use `STRING` as it's value.
|
||||
| `${VAR-STRING}` | If `VAR` is unset, use `STRING` as it's value.
|
||||
| `${VAR:=STRING}` | If `VAR` is empty or unset, set the value of `VAR` to `STRING`.
|
||||
| `${VAR=STRING}` | If `VAR` is unset, set the value of `VAR` to `STRING`.
|
||||
| `${VAR:+STRING}` | If `VAR` isn't empty, use `STRING` as it's value.
|
||||
| `${VAR+STRING}` | If `VAR` is set, use `STRING` as it's value.
|
||||
| `${VAR:?STRING}` | Display an error if empty or unset.
|
||||
| `${VAR?STRING}` | Display an error if unset.
|
||||
```shell
|
||||
echo {apples,oranges,pears,grapes}
|
||||
|
||||
# Example Usage:
|
||||
# Remove dirs Movies, Music and ISOS from ~/Downloads/.
|
||||
rm -rf ~/Downloads/{Movies,Music,ISOS}
|
||||
```
|
||||
|
||||
<!-- CHAPTER END -->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user