Skip to content

Commit

Permalink
Merge pull request #4 from richelbilderbeek/master
Browse files Browse the repository at this point in the history
Ready
  • Loading branch information
richelbilderbeek authored Jan 22, 2024
2 parents 8b4de04 + e3057d9 commit b52acea
Show file tree
Hide file tree
Showing 29 changed files with 1,091 additions and 279 deletions.
31 changes: 31 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,35 @@ UPPMAX
wordlist
www
yml
bilderbeek
CLI
colour
CSVs
dataset
gat
kat
Korona
litres
MacOS
metacharacter
oneliner
personnummer
printf
regexlearn
regextester
repo
RSA
se
sed
uppmax
USD
uu
VVS
wc
wd
whitespace
qat
wat
addr


Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

!!!- info "Learning objectives"

- Practice some basic Linux commands: `echo`, `printf`, `cat`
- Practice some basic Linux commands: `echo`, `printf`, `cat`, `wc`, `rev`
- Practice with Linux pipes
- Use the output of one process as the input for `awk`

???- question "For teachers"

Teaching goals are:

- The learners have practiced with some regular expressions
- The learners have used some online websites to learn regular expressions
- The learners have practiced with UNIX pipes

Lesson plan:

Expand All @@ -29,8 +28,39 @@ The UPPMAX clusters, running Linux, also have `awk`.

Here we discuss the most relevant Linux programs and terms.

```mermaid
flowchart TD
subgraph basic_linux[Basic Linux]
awk
pipes
echo
printf
stdin
files[Files]
input[Input]
cat
editor[Text editor]
wc
rev
tr
end
%% Basic Linux
stdin --> |need to know| pipes
printf --> |need to know| echo
pipes --> |need to know| printf
files --> |need to know| cat
files --> |need to know| editor
files --> |a type of| input
stdin --> |a type of| input
awk --> |reads| input
```

## Exercises

See the exercise procedure [here](../misc/exercise_procedure.md).

### Exercise 1: `echo`

!!!- info "Learning objectives"
Expand Down Expand Up @@ -159,9 +189,10 @@ Do, in a terminal:

- `echo hello world | rev`
- `echo hello world | rev | rev`
- `cat why_awk.txt | wc`
- `cat why_awk.txt | rev`
- `cat why_awk.txt | wc | rev`
- `cat -n why_awk.txt | rev`
- `rev --version | rev`

Express in your own words: what does the pipe symbol `|` do?

127 changes: 121 additions & 6 deletions docs/afternoon_session/overview.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,130 @@
# awk_course
# AWK course

This is the teaching material for the UPPMAX AWK course.
This module introduces the fundamentals of the AWK language.

This repository is based on the material of <https://pmitev.github.io/to-awk-or-not/>
and puts it into teaching cycles.
!!! info "Content"

* [FAQ](faq.md)
This is the teaching material for the UPPMAX AWK course.

This repository is based on the material of <https://pmitev.github.io/to-awk-or-not/>
and puts it into teaching cycles.

## Schedule

Time | Topic
--------------|-------------------------------
13:15-14:00 | [Regular expressions](regexps.md)
14:00-14:15 | Break
14:15-15:00 | [What is AWK](what_is_awk.md), [Basic Linux](basic_linux.md)
15:00-16:00 | Break
15:15-16:00 | [Related tools](related_tools.md)

Extra material:

- [Built-in functions](https://learnbyexample.github.io/learn_gnuawk/built-in-functions.html)
- [Record separators](https://learnbyexample.github.io/learn_gnuawk/record-separators.html)
- [In-place file editing](https://learnbyexample.github.io/learn_gnuawk/in-place-file-editing.html)
- [Multiple-file input](https://learnbyexample.github.io/learn_gnuawk/multiple-file-input.html)

## Overview

### Facets of AWK

```mermaid
flowchart TD
print[Print]
filtering_on_values[Filtering on values]
begin_and_end[BEGIN and END]
variables[Variables]
associative_arrays[Associative arrays]
filtering_on_regex[Filtering on regular expressions]
comma_as_separator[Comma as a separator]
%% Facets of AWK
filtering_on_values --> |needs| print
comma_as_separator --> |needs| print
begin_and_end --> |needs| filtering_on_values
variables --> |needs| begin_and_end
associative_arrays --> |needs| variables
filtering_on_regex --> |needs| filtering_on_values
```

### AWK as a programming language

```mermaid
flowchart TD
%% Give a white background to all nodes, instead of a transparent one
%% classDef node fill:#fff,color:#000,stroke:#000
classDef focus_node fill:#fff,color:#000,stroke-width:4px
subgraph interpreters[Interpreters]
awk
gawk
gnu_awk[GNU Awk]
interpreter
end
subgraph programming_languages[Programming languages]
subgraph compiled_languages[Compiled languages]
compiled_language[Compiled language]
end
subgraph interpreted_languages[Interpreted languages]
interpreted_language[Interpreted language]
AWK:::focus_node
end
end
interpreted_language --> |is run by| interpreter
interpreted_language <--> |is not| compiled_language
awk --> |is a| interpreter
gawk --> |is a| interpreter
gawk --> |is an abbreviation of| gnu_awk
AWK --> |is a| interpreted_language
```

### AWK and its friends

```mermaid
flowchart TD
awk[AWK]
classDef focus_node fill:#fff,color:#000,stroke-width:4px
awk:::focus_node
cut
grep
sed
tr
wc
regexps[Regular expressions]
split_data_in_columns[Split data into columns]
count[Count]
replace[Replace]
%% Tools
awk --> |can do| regexps
sed --> |can do| regexps
grep --> |can do| regexps
awk --> |can do| split_data_in_columns
cut --> |can do| split_data_in_columns
awk --> |can do| count
wc --> |can do| count
awk --> |can do| replace
tr --> |can do| replace
sed --> |can do| replace
```

## Links

* [CLI text processing with GNU awk](https://learnbyexample.github.io/learn_gnuawk/): a book we use
* [To awk or not](https://pmitev.github.io/to-awk-or-not): course material we use
* [AWK cheat sheet](https://catonmat.net/ftp/awk.cheat.sheet.txt)
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Knowing regular expressions allows us to search for patterns in a text.

## Exercises

See the exercise procedure [here](../misc/exercise_procedure.md).

### Exercise 1: practice regular expressions

!!!- info "Learning objectives"
Expand Down Expand Up @@ -204,3 +206,9 @@ Using `awk` only:
- find all the satellites that end with `on` without a vowel (i.e. `aeoui`)
before `on`. For example: `moon` is invalid, as it has the vowel `o` before `on`
- find all the satellites with a number

Think:

- There are two ways to look for regex matches on a whole sentence
(`$0 ~ /my_regex/` and `/my_regex/`). Why is it useful to know
both ways?
Loading

0 comments on commit b52acea

Please sign in to comment.