Begin 2024-02-13 entry.

c-declarations
Joshua Potter 2024-02-13 06:24:57 -07:00
parent 027171a85b
commit c98a083e23
5 changed files with 115 additions and 41 deletions

View File

@ -88,8 +88,8 @@
"bash/shebang.md": "9006547710f9a079a3666169fbeda7aa", "bash/shebang.md": "9006547710f9a079a3666169fbeda7aa",
"c/escape-sequences.md": "0d6219ebb51f6f21e026de67603e25b8", "c/escape-sequences.md": "0d6219ebb51f6f21e026de67603e25b8",
"c/index.md": "a021c92f19831bdd2bca4cbf813882fe", "c/index.md": "a021c92f19831bdd2bca4cbf813882fe",
"gawk/index.md": "0a305a0477085fd2f4145536735ca94a", "gawk/index.md": "dd851e023e11c556c0272a0dcb6dd55d",
"gawk/variables.md": "7408f450957ab007fbdbd687121da0d3", "gawk/variables.md": "a9cd0344390974b3bfdf794d75d434e5",
"index.md": "e48e895feeed7046425bb2ee15419770", "index.md": "e48e895feeed7046425bb2ee15419770",
"journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970", "journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970",
"journal/2024-02-01.md": "3aa232387d2dc662384976fd116888eb", "journal/2024-02-01.md": "3aa232387d2dc662384976fd116888eb",
@ -152,7 +152,9 @@
"c/strings.md": "38f9cf9e2325565589f62e191221a83a", "c/strings.md": "38f9cf9e2325565589f62e191221a83a",
"logic/truth-tables.md": "7892ceaa416c9a65acc79ca1e6ff778f", "logic/truth-tables.md": "7892ceaa416c9a65acc79ca1e6ff778f",
"logic/short-circuit.md": "26d300f407f14883022d0ef8dc4f7300", "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": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -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`.

View File

@ -27,13 +27,6 @@ END%%
The above quote is attributed to Brian Kernighan (one of the authors of the [[C]] K&R book). 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)
<!--ID: 1706726911442-->
END%%
## Setup ## Setup
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.
@ -129,14 +122,6 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
<!--ID: 1707310981378--> <!--ID: 1707310981378-->
END%% 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)
<!--ID: 1707310981380-->
END%%
%%ANKI %%ANKI
Basic Basic
In `awk`, what does a "field" refer to? In `awk`, what does a "field" refer to?

View File

@ -73,25 +73,9 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
<!--ID: 1707405259925--> <!--ID: 1707405259925-->
END%% END%%
* `RS` (**R**ecord **S**eparator)
* The separator used to distinguish records from one another.
* `RT` (**R**ecord **T**ext) * `RT` (**R**ecord **T**ext)
* The matching separator used to distinguish the currently read record. * 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)
<!--ID: 1707310981382-->
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)
<!--ID: 1707310981384-->
END%%
%%ANKI %%ANKI
Cloze Cloze
The {`RT`} variable matches the {input characters that matched `RS`}. The {`RT`} variable matches the {input characters that matched `RS`}.
@ -107,6 +91,39 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
<!--ID: 1707310981388--> <!--ID: 1707310981388-->
END%% 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)
<!--ID: 1707310981382-->
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)
<!--ID: 1707310981380-->
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)
<!--ID: 1707310981384-->
END%%
%%ANKI %%ANKI
Basic Basic
What value of `RS` may `gawk` not process correctly? What value of `RS` may `gawk` not process correctly?
@ -131,11 +148,31 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
<!--ID: 1707310981394--> <!--ID: 1707310981394-->
END%% 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)
<!--ID: 1707829409163-->
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)
<!--ID: 1707829409170-->
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)
<!--ID: 1707829509362-->
END%%
* `NF` (**N**umber of **F**ields) * `NF` (**N**umber of **F**ields)
* The 1-indexed number of fields found in the current record. * 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 %%ANKI
Basic Basic
@ -168,6 +205,33 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
<!--ID: 1707405259930--> <!--ID: 1707405259930-->
END%% 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)
<!--ID: 1707829863717-->
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)
<!--ID: 1707829863726-->
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 %%ANKI
Cloze Cloze
The {`FS`} variable is used to change the {field separator}. The {`FS`} variable is used to change the {field separator}.
@ -208,7 +272,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What distinguishes `FS` value `" "` and `[ \t\n]+`? 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) 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: 1707618833558--> <!--ID: 1707618833558-->
END%% END%%
@ -222,7 +286,7 @@ END%%
%%ANKI %%ANKI
Cloze 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) 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: 1707756447067--> <!--ID: 1707756447067-->
END%% END%%
@ -230,7 +294,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What value of `FS` ensures `$1 = $0`? 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) 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: 1707756447069--> <!--ID: 1707756447069-->
END%% END%%
@ -243,6 +307,16 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202
<!--ID: 1707756447071--> <!--ID: 1707756447071-->
END%% 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)
<!--ID: 1707829783790-->
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)