diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index 1c5623b..bddb41b 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -88,8 +88,8 @@ "bash/shebang.md": "9006547710f9a079a3666169fbeda7aa", "c/escape-sequences.md": "0d6219ebb51f6f21e026de67603e25b8", "c/index.md": "a021c92f19831bdd2bca4cbf813882fe", - "gawk/index.md": "0a305a0477085fd2f4145536735ca94a", - "gawk/variables.md": "7408f450957ab007fbdbd687121da0d3", + "gawk/index.md": "dd851e023e11c556c0272a0dcb6dd55d", + "gawk/variables.md": "a9cd0344390974b3bfdf794d75d434e5", "index.md": "e48e895feeed7046425bb2ee15419770", "journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970", "journal/2024-02-01.md": "3aa232387d2dc662384976fd116888eb", @@ -152,7 +152,9 @@ "c/strings.md": "38f9cf9e2325565589f62e191221a83a", "logic/truth-tables.md": "7892ceaa416c9a65acc79ca1e6ff778f", "logic/short-circuit.md": "26d300f407f14883022d0ef8dc4f7300", - "logic/boolean-algebra.md": "c5d699d407e03d280aa1f201bc3e8b02" + "logic/boolean-algebra.md": "c5d699d407e03d280aa1f201bc3e8b02", + "_journal/2024-02-13.md": "75ba5d7d77862c50a172a59415ec6a84", + "_journal/2024-02/2024-02-12.md": "618c0035a69b48227119379236a02f44" }, "fields_dict": { "Basic": [ diff --git a/notes/_journal/2024-02-13.md b/notes/_journal/2024-02-13.md new file mode 100644 index 0000000..7fe40b9 --- /dev/null +++ b/notes/_journal/2024-02-13.md @@ -0,0 +1,13 @@ +--- +title: "2024-02-13" +--- + +- [x] Anki Flashcards +- [x] KoL +- [ ] Sheet Music (10 min.) +- [ ] OGS (1 Life & Death Problem) +- [ ] Korean (Read 1 Story) +- [ ] Interview Prep (1 Practice Problem) +- [ ] Log Work Hours (Max 3 hours) + +* Read more on record and field separators in `gawk`. \ No newline at end of file diff --git a/notes/_journal/2024-02-12.md b/notes/_journal/2024-02/2024-02-12.md similarity index 100% rename from notes/_journal/2024-02-12.md rename to notes/_journal/2024-02/2024-02-12.md diff --git a/notes/gawk/index.md b/notes/gawk/index.md index 4c60f84..d847fa7 100644 --- a/notes/gawk/index.md +++ b/notes/gawk/index.md @@ -27,13 +27,6 @@ END%% The above quote is attributed to Brian Kernighan (one of the authors of the [[C]] K&R book). -%%ANKI -Cloze -Dark corners are basically {1:fractal} - {1:no matter how much you illuminate, there's always a smaller but darker one.} - Brian Kernighan -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) - -END%% - ## Setup Robbins suggests executing command `set +H` on [[bash]] startup to disable [[C]] shell-style command history. @@ -129,14 +122,6 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% -%%ANKI -Basic -What is the default record separator? -Back: The newline character. -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) - -END%% - %%ANKI Basic In `awk`, what does a "field" refer to? diff --git a/notes/gawk/variables.md b/notes/gawk/variables.md index 42b3f1b..a4cb8f0 100644 --- a/notes/gawk/variables.md +++ b/notes/gawk/variables.md @@ -73,25 +73,9 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% -* `RS` (**R**ecord **S**eparator) - * The separator used to distinguish records from one another. * `RT` (**R**ecord **T**ext) * The matching separator used to distinguish the currently read record. -%%ANKI -Cloze -The {`RS`} variable is used to change the {record separator}. -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) - -END%% - -%%ANKI -Cloze -If `RS` is a string with {more than one character}, it is treated as a {regexp}. -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) - -END%% - %%ANKI Cloze The {`RT`} variable matches the {input characters that matched `RS`}. @@ -107,6 +91,39 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% +* `RS` (**R**ecord **S**eparator) + * The separator used to distinguish records from one another. + * Defaults to `"\n"`. + +`RS == ??` | Description +---------------------- | ------------------------------------- +`"\n"` | Records are separated by the newline character. This is the default. +*any single character* | Records are separated by each occurrence of the character. Multiple successive occurrences delimit empty records. +`""` | Records are separated by runs of blank lines. Leading/trailing newlines in a file are ignored. If `FS` is a single character, then `"\n"` also serves as a field separator. +*regexp* | Records are separated by occurrences of characters that match *regexp*. Leading/trailing matches delimit empty records. + +%%ANKI +Cloze +The {`RS`} variable is used to change the {record separator}. +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) + +END%% + +%%ANKI +Basic +What is the default value of `RS`? +Back: `"\n"` +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) + +END%% + +%%ANKI +Cloze +If `RS` is a string with {more than one character}, it is treated as a {regexp}. +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) + +END%% + %%ANKI Basic What value of `RS` may `gawk` not process correctly? @@ -131,11 +148,31 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% +%%ANKI +Basic +How is `RS = ""` interpreted? +Back: `""` indicates runs of newlines should be treated as the record separator. +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) + +END%% + +%%ANKI +Basic +What distinguishes `RS` value `""` and `\n\n+`? +Back: When set to the former, `awk` strips leading/trailing newlines from the file. +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) + +END%% + +%%ANKI +Cloze +If `RS = ""` and `FS` is set to {a single character}, the {newline character} *always* acts as a field separator. +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) + +END%% + * `NF` (**N**umber of **F**ields) * The 1-indexed number of fields found in the current record. -* `FS` (**F**ield **S**eparator) - * The separator used to distinguish fields from one another. - * Defaults to `" "` which is a special character for **runs** of spaces, tabs, and newlines. %%ANKI Basic @@ -168,6 +205,33 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% +%%ANKI +Basic +What does incrementing `NF` do? +Back: Creates the field and rebuilds the record. +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) + +END%% + +%%ANKI +Basic +What does decrementing `NF` do? +Back: Throws away fields and rebuilds the record. +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) + +END%% + +* `FS` (**F**ield **S**eparator) + * The separator used to distinguish fields from one another. + +`FS == ??` | Description +---------------------------- | ------------------------------------- +`" "` | Fields are separated by runs of whitespace. Leading/trailing whitespace is ignored. This is the default. +*any other single character* | Fields are separated by each occurrence of the character. Multiple successive occurrences delimit empty fields, as do leading/trailing occurrences. +`"\n"` | Specific instance of the above row. It is used to treat the record as a single field (assuming newlines separate records). +*regexp* | Fields are separated by occurrences of characters that match *regexp*. Leading/trailing matches delimit empty fields. +`""` | Each individual character in the record becomes a separate field. + %%ANKI Cloze The {`FS`} variable is used to change the {field separator}. @@ -208,7 +272,7 @@ END%% %%ANKI Basic What distinguishes `FS` value `" "` and `[ \t\n]+`? -Back: When set to the former, `awk` strips leading and trailing whitespace from each record. +Back: When set to the former, `awk` strips leading/trailing whitespace from each record. 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) END%% @@ -222,7 +286,7 @@ END%% %%ANKI Cloze -Setting `FS` to {`"\n"`} treats the {record as the single field}. +If `RS` has its default value, setting `FS` to {`"\n"`} treats the {record as the single field}. 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) END%% @@ -230,7 +294,7 @@ END%% %%ANKI Basic What value of `FS` ensures `$1 = $0`? -Back: `"\n"` +Back: `RS` 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) END%% @@ -243,6 +307,16 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% +* `OFS` (**O**utput **F**ield **S**eparator) + * Specifies the field separator used on printing. + +%%ANKI +Cloze +The {`OFS`} variable is used to change the {output field separator}. +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) + +END%% + ## 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) \ No newline at end of file +* 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)