awk

    awk command for MoonX.

    command-line
    moonx
    wasm
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    14 hours ago
    Downloads
    9

    #awk

    Run pattern-action programs over UTF-8 records. This development command runs from the repository on Linux, macOS and Windows.

    #Usage

    moon run --target wasm commands/awk -- -F : '{ print $1, $3 }' accounts.txt moon run --target wasm commands/awk -- '{ sum[$1] += $2 } END { for (k in sum) print k, sum[k] }' data.txt

    #Common options

    OptionDescription
    -F VALUE, --field-separator VALUESet the field separator.
    -v VALUE, --assign VALUEAssign a variable before BEGIN.
    -f VALUE, --file VALUERead program text from a file.
    -e VALUE, --source VALUEAdd a program fragment.
    --csvRead quoted CSV records and fields.
    --helpShow help.
    --versionShow the version.

    #Notes

    BEGIN runs before input and END follows normal completion or an explicit exit. Patterns support expressions, EREs and ranges. Actions can update fields, call functions, accumulate associative arrays, use printf, or skip records and files. Repeated -e and -f fragments run in command-line order. An assignment operand applies when that position in ARGV is reached.

    Ordinary LF records stream from standard input and files. Custom RS, CSV and main-input getline and dynamic getline file names use the interpreter's pull reader. This reader consumes named files in chunks and buffers standard input. Program text and input must be valid UTF-8. The interpreter enforces its record, string and execution budgets. Local file redirection supports reading, truncation, append and close. Process pipes and system() produce a diagnostic and status 2. Explicit exit codes are preserved. Native GNU extensions beyond this profile are unverified.

    Source Files