Pattern scanning and processing language.
Synopsis
awk [OPTIONS] 'PROGRAM' [FILE]...
Description
Process text files by applying pattern-action pairs to each record (line). Supports variables, built-in functions, field splitting, and more. Runs in the just-bash WASM shell inside SLICC.
Options
-F SEP, --field-separator=SEP Set the field separator (default: whitespace).
-v VAR=VAL Assign a value to a variable before execution.
Built-in Variables
$0 The entire current record (line).
$1, $2, ... Individual fields of the current record.
NF Number of fields in the current record.
NR Current record (line) number.
FS Field separator (set by -F or within program).
OFS Output field separator (default: space).
ORS Output record separator (default: newline).
Examples
$ awk '{print $1}' file.txt
Print the first field of each line.
$ awk -F',' '{print $2}' data.csv
Print the second column of a CSV file.
$ awk 'NR==5,NR==10' file.txt
Print lines 5 through 10.
$ awk '{sum += $1} END {print sum}' numbers.txt
Sum the first column.
Notes
Operates on the SLICC virtual filesystem (LightningFS/IndexedDB). Implements a subset of POSIX awk. Supports BEGIN/END blocks, pattern-action rules, basic string functions (length, substr, index, split, sub, gsub, match, tolower, toupper, sprintf), and math functions.
See Also
sed, cut, grep, sort