Lessons

AWK · Introductory

AWK · Introductory. Ten lessons. Open-book quizzes. Lesson 1 free.

10 lessons · The Host · Lesson 1 free

Pass all ten lessons for the certificate. Sample · Claim

  1. Hello, AWK: running gawk, BEGIN and print

    Lesson 1 · On the house

    Hello, AWK: running gawk, BEGIN and print

    Run AWK programs with gawk, learn the pattern-action shape, and print text, numbers and formatted output from a BEGIN block.

  2. Patterns and actions

    Lesson 2

    Patterns and actions

    Select lines with regex patterns, comparisons and boolean combinations, rely on the default print action, and skip records with next.

  3. Fields: $0, $1, NF, FS and OFS

    Lesson 3

    Fields: $0, $1, NF, FS and OFS

    Split records into fields, read them with $1 and $NF, change the input separator FS and the output separator OFS, and rebuild records.

  4. Variables, arithmetic, strings and sprintf

    Lesson 4

    Variables, arithmetic, strings and sprintf

    Use AWK's untyped variables, arithmetic and assignment operators, string concatenation, number-string conversion and sprintf formatting.

  5. Control flow: if, loops, next and exit

    Lesson 5

    Control flow: if, loops, next and exit

    Branch with if/else and the ?: operator, loop with while, do-while and for, leave loops with break and continue, and stop input with exit.

  6. Associative arrays, for-in and delete

    Lesson 6

    Associative arrays, for-in and delete

    Count and total by key with associative arrays, test keys with in, loop with for-in, sort output through a pipe and remove elements with delete.

  7. String functions: length, substr, index, split, sub and gsub

    Lesson 7

    String functions: length, substr, index, split, sub and gsub

    Measure and slice strings, search with index and match, split into arrays, change case and replace text with sub and gsub.

  8. Numeric functions, output redirection and getline

    Lesson 8

    Numeric functions, output redirection and getline

    Use int, sqrt, exp, log, atan2 and rand, write to files with > and >>, read files and command output with getline, and close streams.

  9. BEGIN and END, NR, FNR, FILENAME and multiple files

    Lesson 9

    BEGIN and END, NR, FNR, FILENAME and multiple files

    Print headers in BEGIN and totals in END, tell records apart across files with NR, FNR and FILENAME, and join two files with the NR == FNR idiom.

  10. User functions and a complete report

    Lesson 10

    User functions and a complete report

    Define functions with parameters and return, declare locals as extra parameters, pass arrays by reference, and build a grouped CSV report.

Sample certificate

Certificate of completion

Sign in to claim your certificate of completion.

Certificate

Finish all ten lessons, then sign in

Pass every lesson on this device (quizzes and checks). Then sign in or create an account to type your name and download the JPG.

All lessons