Add notes.
parent
7e28ba2efd
commit
413d48c4d1
|
@ -64,15 +64,17 @@
|
||||||
"daily/2024-01-31.md": "72e343cef8d56e169cac7b360a88fcf0",
|
"daily/2024-01-31.md": "72e343cef8d56e169cac7b360a88fcf0",
|
||||||
"posix/index.md": "f7b1ae55f8f5e8f50f89738b1aca9111",
|
"posix/index.md": "f7b1ae55f8f5e8f50f89738b1aca9111",
|
||||||
"posix/signals.md": "2120ddd933fc0d57abb93c33f639afd8",
|
"posix/signals.md": "2120ddd933fc0d57abb93c33f639afd8",
|
||||||
"gawk.md": "4517acfbf4e186e8cc66a9002fbad73f",
|
"gawk.md": "c79a09e1772da1d4f2cd296b7370ecab",
|
||||||
"bash/index.md": "3b5296277f095acdf16655adcdf524af",
|
"bash/index.md": "3b5296277f095acdf16655adcdf524af",
|
||||||
"bash/shebang.md": "ad178efeb4a05190b80b5df108c175c7",
|
"bash/shebang.md": "9006547710f9a079a3666169fbeda7aa",
|
||||||
"bash/robustness.md": "de97cd77aae047b5eea27440b43c9c42",
|
"bash/robustness.md": "de97cd77aae047b5eea27440b43c9c42",
|
||||||
"journal/2024-02-01.md": "f4cc061bfc8e41ce15ae9a354c65ffe9",
|
"journal/2024-02-01.md": "3aa232387d2dc662384976fd116888eb",
|
||||||
"journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970",
|
"journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970",
|
||||||
"bash/quoting.md": "b1d8869a91001f8b22f0cdc54d806f61",
|
"bash/quoting.md": "b1d8869a91001f8b22f0cdc54d806f61",
|
||||||
"nix/callPackage.md": "5ef6bc5d1a549c55d43ebb4d48c64427",
|
"nix/callPackage.md": "5ef6bc5d1a549c55d43ebb4d48c64427",
|
||||||
"nix/index.md": "dd5ddd19e95d9bdbe020c68974d77a33"
|
"nix/index.md": "dd5ddd19e95d9bdbe020c68974d77a33",
|
||||||
|
"journal/2024-02-02.md": "0df6266a5f347124df5ac795bcff51a2",
|
||||||
|
"bash/prompts.md": "64bd3cd3c2feb9edb68ad8dc5ba65a35"
|
||||||
},
|
},
|
||||||
"fields_dict": {
|
"fields_dict": {
|
||||||
"Basic": [
|
"Basic": [
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
---
|
||||||
|
title: Prompts
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: bash
|
||||||
|
tags:
|
||||||
|
- bash
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
According to Robbins a POSIX-compliant shell (like Bash) generally has the primary and secondary prompts denoted with `$` and `>` respectively.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What symbol is usually used to denote the primary prompt?
|
||||||
|
Back: `$$`
|
||||||
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
|
<!--ID: 1706882670149-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What symbol is usually used to denote the secondary prompt?
|
||||||
|
Back: `>`
|
||||||
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
|
<!--ID: 1706882670158-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
Paths supplied to commands are typically "sanitized" by prefixing the path name with `./`. This is mentioned in a few different places:
|
||||||
|
|
||||||
|
* `find -execdir` performs this prefixing automatically on all found files.
|
||||||
|
* `awk` ambiguously interprets a file named e.g. `count=1` as variable assignment. Should write `$ awk -f program.awk ./count=1`.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What methodology is commonly used to "sanitize" paths supplied as command-line arguments?
|
||||||
|
Back: Prefixing the paths with `./`.
|
||||||
|
Reference: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
|
||||||
|
<!--ID: 1706885111460-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
* Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916.
|
||||||
|
* Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
|
@ -8,7 +8,7 @@ tags:
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
The shebang (also writting shabang or sha-bang) is a magic character at the start of a script indicating what command should be run when invoking the script directly. It always begins with ASCII characters `#!`.[^mendel]
|
The shebang (also writting shabang or sha-bang) is a magic character at the start of a script indicating what command should be run when invoking the script directly. It always begins with ASCII characters `#!`.
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
|
|
|
@ -40,7 +40,7 @@ END%%
|
||||||
|
|
||||||
Robbins suggests executing command `set +H` on [[bash]] startup to disable [[C]] shell-style command history.
|
Robbins suggests executing command `set +H` on [[bash]] startup to disable [[C]] shell-style command history.
|
||||||
|
|
||||||
## Usage
|
## Structure
|
||||||
|
|
||||||
`awk` applies actions to lines matching specified patterns. In this way `awk` is said to be data-driven - we specify the lines `awk` should act on and `awk` is responsible for finding and acting on them. Instructions are provided via a **program**.
|
`awk` applies actions to lines matching specified patterns. In this way `awk` is said to be data-driven - we specify the lines `awk` should act on and `awk` is responsible for finding and acting on them. Instructions are provided via a **program**.
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ Basic
|
||||||
Write the `awk` command that searches file `mail-list` for string `li`.
|
Write the `awk` command that searches file `mail-list` for string `li`.
|
||||||
Back:
|
Back:
|
||||||
```bash
|
```bash
|
||||||
$ awk '/li/ { print }' mail-list
|
$ awk '/li/' mail-list
|
||||||
```
|
```
|
||||||
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
<!--ID: 1706819150999-->
|
<!--ID: 1706819150999-->
|
||||||
|
@ -141,7 +141,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What is the `BEGIN` pattern?
|
How is the `BEGIN` pattern interpreted?
|
||||||
Back: Code associated with it executes before any input is read.
|
Back: Code associated with it executes before any input is read.
|
||||||
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
<!--ID: 1706823790236-->
|
<!--ID: 1706823790236-->
|
||||||
|
@ -149,7 +149,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What is the `END` pattern?
|
How is the `END` pattern interpreted?
|
||||||
Back: Code associated with it executes after all input has been read.
|
Back: Code associated with it executes after all input has been read.
|
||||||
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
<!--ID: 1706823790239-->
|
<!--ID: 1706823790239-->
|
||||||
|
@ -188,6 +188,49 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
|
||||||
<!--ID: 1706824091128-->
|
<!--ID: 1706824091128-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
`awk` is said to be a "line-oriented" language. Every rule's action must begin on the same line as the pattern.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
When can a rule's pattern and action exist on different lines?
|
||||||
|
Back: Only when using backslash continuation.
|
||||||
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
|
<!--ID: 1706883732944-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
Variables are defined like `var=val`. They can be specified in two different places:
|
||||||
|
|
||||||
|
1. Via the `-v` command line flag. Using this allows accessing the variable value from within a `BEGIN` rule.
|
||||||
|
2. In the file list. Using this allows accessing the variable value in all subsequent file processing.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Where in an `awk` invocation can variables be assigned?
|
||||||
|
Back: As a `-v` argument or in the file list.
|
||||||
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
|
<!--ID: 1706885111450-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
The `-v` flag was introduced to accommodate what functionality?
|
||||||
|
Back: Accessing variables from a `BEGIN` rule.
|
||||||
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
|
<!--ID: 1706885111454-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Describe what the following command does in in a single sentence:
|
||||||
|
```bash
|
||||||
|
$ awk 'program' pass=1 data pass=2 data
|
||||||
|
```
|
||||||
|
Back: Evaluates `'program'` against the `data` file twice with a different value of `pass` on each run.
|
||||||
|
Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
||||||
|
<!--ID: 1706885111457-->
|
||||||
|
END%%
|
||||||
## References
|
## References
|
||||||
|
|
||||||
* Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
* Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 2023. [https://www.gnu.org/software/gawk/manual/gawk.pdf](https://www.gnu.org/software/gawk/manual/gawk.pdf)
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
title: "2024-02-02"
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] Anki Flashcards
|
||||||
|
- [x] KoL
|
||||||
|
- [x] Sheet Music (10 min.)
|
||||||
|
- [x] OGS (1 Life & Death Problem)
|
||||||
|
- [x] Korean (Read 1 Story)
|
||||||
|
- [ ] Interview Prep (1 Practice Problem)
|
||||||
|
- [ ] Log Work Hours (Max 3 hours)
|
||||||
|
|
||||||
|
* Read 효자 호랑이 (The Filial Tiger).
|
||||||
|
* Read through [Project #1 - Buffer Pool](https://15445.courses.cs.cmu.edu/fall2022/project1/) in anticipation of my call with Kevin later.
|
Loading…
Reference in New Issue