diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index c1a444c..c9f6fab 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -60,14 +60,17 @@ "Linux/Signals.md": "f58f1a36a9fe53928fdc3dc02fc4c3e3", "linux/index.md": "6e50c924ee9e09294fd3b907fbdeaf0f", "linux/signals.md": "e9ab74723981ebc232189c84d3b0da74", - "templates/daily.md": "0f22c7ef0b0f35efada88d61c95e9815", + "templates/daily.md": "7866014e730e85683155207a02e367d8", "daily/2024-01-31.md": "72e343cef8d56e169cac7b360a88fcf0", "posix/index.md": "f7b1ae55f8f5e8f50f89738b1aca9111", - "posix/signals.md": "26161c6a79a0c413032c6c17e460412c", - "gawk.md": "9bf70ef138a9a281b86400aee393cae7", + "posix/signals.md": "2120ddd933fc0d57abb93c33f639afd8", + "gawk.md": "c0cf6decdf02f5513e386525b02bdf58", "bash/index.md": "3b5296277f095acdf16655adcdf524af", - "bash/shebang.md": "bc30f75bcddff59d6f907fae89c17283", - "bash/robustness.md": "e474fd33469fc393bfde45cd7b9411ba" + "bash/shebang.md": "ad178efeb4a05190b80b5df108c175c7", + "bash/robustness.md": "de97cd77aae047b5eea27440b43c9c42", + "journal/2024-02-01.md": "f4cc061bfc8e41ce15ae9a354c65ffe9", + "journal/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970", + "bash/quoting.md": "8086c0a576f30d77248faac16a4be79e" }, "fields_dict": { "Basic": [ diff --git a/notes/bash/quoting.md b/notes/bash/quoting.md new file mode 100644 index 0000000..c65e09f --- /dev/null +++ b/notes/bash/quoting.md @@ -0,0 +1,47 @@ +--- +title: Quoting +TARGET DECK: Obsidian::STEM +FILE TAGS: bash +tags: + - bash +--- + +%%ANKI +Basic +How do you escape a `'` within a single-quote string? +Back: This is impossible. +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 the null string refer to? +Back: The empty string, i.e. `""`. +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 +When does Bash remove null strings from a command? +Back: When they occur as part of a non-null command-line argument. +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 wrong with the following command? +```bash +$ # -F specifies the field separator +$ awk -F"" 'program' files +``` +Back: Bash removes the null string before executing the command. +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 diff --git a/notes/bash/robustness.md b/notes/bash/robustness.md index 9e67484..ffbc400 100644 --- a/notes/bash/robustness.md +++ b/notes/bash/robustness.md @@ -7,7 +7,9 @@ tags: - shell --- -An interesting point Robbins[^robbins] discusses in his introduction to [[gawk]] is this idea of command robustness. He states that: +## Overview + +An interesting point Robbins discusses in his introduction to [[gawk]] is this idea of command robustness. He states that: > A self-contained shell script is more reliable because there are no other files to misplace. @@ -27,7 +29,7 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% -The point he is arguing is that the first command below is considered more robust than the second since the command is more loosely coupled to its environment: +He argues that the first command below is more robust than the second since the command is more loosely coupled to its environment: ```bash $ awk 'program' input-file1 input-file2 ... @@ -55,4 +57,6 @@ It's interesting to think what else can be used as a measure of a command's robu * Whether a program acts atomically * Is it possible intermediate files are left that affect subsequent runs? -[^robbins]: 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) +## 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) diff --git a/notes/bash/shebang.md b/notes/bash/shebang.md index 34ccf02..25e10f4 100644 --- a/notes/bash/shebang.md +++ b/notes/bash/shebang.md @@ -6,6 +6,8 @@ tags: - bash --- +## 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] %%ANKI @@ -44,12 +46,13 @@ Some systems limit the length of interpreters to just 32 characters. A simple wo %%ANKI Basic -What workaround is used when shabang interpreter names are too long? +What workaround is used when shebang interpreter names are too long? Back: Introduce a symbolic link. 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%% -[^mendel]: Cooper, Mendel. “Advanced Bash-Scripting Guide,” n.d., 916. +## References -[^robbins]: 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 +* 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) \ No newline at end of file diff --git a/notes/gawk.md b/notes/gawk.md index c472189..c13b809 100644 --- a/notes/gawk.md +++ b/notes/gawk.md @@ -8,7 +8,7 @@ tags: - gawk --- -## Introduction +## Overview %%ANKI Basic @@ -25,7 +25,7 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% -> Dark corners are basically fractal - no matter how much you illuminate, there's always a smaller but darker one. +> Dark corners are basically fractal - no matter how much you illuminate, there's always a smaller but darker one. #quote The above quote is attributed to Brian Kernighan (one of the authors of the [[C]] K&R book). @@ -83,4 +83,111 @@ Reference: Robbins, Arnold D. “GAWK: Effective AWK Programming,” October 202 END%% -[^robbins]: 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) +%%ANKI +Basic +Write the `awk` command that searches file `mail-list` for string `li`. +Back: +```bash +$ awk '/li/ { print }' 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) + +END%% + +%%ANKI +Basic +How is an `awk` rule without a pattern interpreted? +Back: As applying the specified action for every input line. +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 +How is an `awk` rule without an action interpreted? +Back: As printing every line matching the specified pattern. +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 +Describe what the following command does in in a single sentence: +```bash +$ awk 'length($0) > 80' data +``` +Back: Prints every line of `data` that is longer than `80` characters. +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%% + +**Targets** are specified as `$n` where `n` is a placeholder for the `n`th whitespace-separated **field**s of the input line. For example, `$1` refers to the first field of the input line. `$0` is a special target referring to the entire list of arguments, i.e. the entire line. + +%%ANKI +Basic +What is `$0` a placeholder for? +Back: The entire input line. +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 `$1` a placeholder for? +Back: The first field of the input line. +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 `BEGIN` pattern? +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) + +END%% + +%%ANKI +Basic +What is the `END` pattern? +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) + +END%% + +%%ANKI +Basic +Describe what the following command does in in a single sentence: +```bash +$ awk 'NF > 0' data +``` +Back: Prints every line of `data` with at least one 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%% + +%%ANKI +Basic +Describe what the following command does in in a single sentence: +```bash +$ awk 'END { print NR }' data +``` +Back: Prints the number of lines in `data`. +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 +Describe what the following command does in in a single sentence: +```bash +$ awk 'NR % 2 == 0' data +``` +Back: Prints every even-numbered line in `data`. +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 diff --git a/notes/posix/signals.md b/notes/posix/signals.md index d563053..29916c9 100644 --- a/notes/posix/signals.md +++ b/notes/posix/signals.md @@ -7,7 +7,9 @@ tags: - signal --- -This is an overview of specific POSIX signals.[^dowling] +## Overview + +This is an overview of specific POSIX signals. Code | Name ----- | -------------- @@ -112,4 +114,33 @@ Reference: `man 1 ps` END%% -[^dowling]: Dowling, “A List of Signals and What They Mean.” +### SIGINT (2) + +Indicates the process was interrupted by the user. Happens when pressing `Ctrl-C` from the controlling terminal. + +%%ANKI +Cloze +Signal {`SIGINT`} corresponds to number {2}. +Reference: Dowling, “A List of Signals and What They Mean.” + +END%% + +%%ANKI +Basic +What control sequence usually triggers a `SIGINT`? +Back: `Ctrl-C` +Reference: Dowling, “A List of Signals and What They Mean.” + +END%% + +%%ANKI +Basic +What is the `INT` in `SIGINT` short for? +Back: **Int**errupt +Reference: Dowling, “A List of Signals and What They Mean.” + +END%% + +## References + +* Dowling, “A List of Signals and What They Mean.”