generated from jackyzha0/quartz
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
164 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
--- | ||
title: Bash Expansions | ||
tags: | ||
- command_line | ||
- bash | ||
--- | ||
```bash | ||
variable="value" | ||
echo ${variable} # → value | ||
echo $variable # → value | ||
``` | ||
|
||
Curly braces are used to delimit the variable. | ||
|
||
```bash | ||
echo ${variable}_ # → value_ | ||
echo $variable_ # → (empty) | ||
|
||
set -o nounset | ||
echo $variable_ # exits with error "unbound variable" | ||
``` | ||
|
||
## Variable indirection | ||
|
||
```bash | ||
variable="HOME" | ||
echo ${!variable} # /usr/alpha | ||
``` | ||
|
||
## Uppercase | ||
|
||
```bash | ||
variable="value" | ||
|
||
echo ${variable} # → value | ||
echo ${variable^} # → Value | ||
echo ${variable^^} # → VALUE | ||
``` | ||
|
||
## Lowercase | ||
|
||
```bash | ||
variable="VALUE" | ||
echo ${variable} # → VALUE | ||
echo ${variable,} # → vALUE | ||
echo ${variable,,} # → value | ||
``` | ||
|
||
## Pattern matching | ||
|
||
```bash | ||
variable="VALUE" | ||
echo ${variable,,[VAL]} # → valUE | ||
echo ${variable,,[LUE]} # → VAlue | ||
|
||
variable="value" | ||
echo ${variable^^[va]} # → VAlue | ||
``` | ||
|
||
## Arrays | ||
|
||
```bash | ||
variables=(one two three) | ||
echo ${variables[@]} # → one two three | ||
echo ${variables[@]^} # → One Two Three | ||
echo ${variables[@]^^} # → ONE TWO THREE | ||
echo ${variables[@]^^[oe]} # → OnE twO thrEE | ||
echo ${variables[*]^^[oe]} # → OnE twO thrEE | ||
|
||
echo ${variables[2]^^} # → THREE | ||
``` | ||
|
||
## Substring removal | ||
|
||
### From begginning of string | ||
|
||
```bash | ||
variable="value1 value2" | ||
echo ${variable#va} # → lue1 value2 | ||
echo ${variable#val} # → ue1 value2 | ||
echo ${variable#*l} # → ue1 value2 | ||
echo ${variable##val} # → ue1 value2 | ||
echo ${variable##*l} # → ue2 | ||
``` | ||
|
||
### From end of string | ||
|
||
```bash | ||
variable="value1 value2" | ||
echo ${variable%lue2} # → value1 va | ||
echo ${variable%al*} # → value1 v | ||
echo ${variable%*l*} # → value1 va | ||
``` | ||
|
||
## String replacement | ||
|
||
```bash | ||
echo ${variable/value/example} # → example1 value2 | ||
echo ${variable//#value/example} # → example1 example2 | ||
echo ${variable/#value/example} # → example1 value2 | ||
echo ${variable/value*/example} # → example | ||
echo ${variable/%value2/example} # → value1 example | ||
``` | ||
|
||
## Substring | ||
|
||
```bash | ||
echo ${variable:4} # → e1 value2 | ||
echo ${variable:2:3} # → lue | ||
# The space before the - sign is required | ||
echo ${variable: -3} # → ue2 | ||
echo ${variable:1: -1} # → alue1 value | ||
echo ${variable: -3: -1} # → ue | ||
``` | ||
|
||
## Length | ||
|
||
```bash | ||
echo ${#variable} # → 13 | ||
echo ${#variables[@]} # → 3 | ||
echo ${#variables[2]} # → 5 | ||
``` | ||
|
||
[^linuxConfig]: [Introduction to Bash Shell Parameter Expansions](https://linuxconfig.org/introduction-to-bash-shell-parameter-expansions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Polyphasic Sleep | ||
tags: | ||
- health | ||
--- | ||
Polyphasic sleep is the practice of sleeping in numerous smaller blocks during the day as opposed to sleeping once as is common in many countries.[^PS] | ||
|
||
[^PS]: https://www.polyphasic.net/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: LazyAxolotl | ||
tags: | ||
- llm | ||
--- | ||
Pre-built notebook with YAML-based configuration to download, run and fine-tune a LLM. | ||
|
||
https://colab.research.google.com/drive/1TsDKNo2riwVmU55gjuBgB1AXVtRRfRHW |