Karthik Divi
·2 min read

AWK Online Compiler

AWK is one of the original Unix text processing tools, created by Aho, Weinberger, and Kernighan (yes, the K from K&R C). It processes input line by line, splitting each line into fields, and lets you write pattern-action rules to extract and transform data. If you've ever piped something through awk '{print $2}' in a terminal, you've already used it.

Most AWK programs are short. Many are one-liners. That's the point -- AWK was built for quick column extraction, text filtering, and data summarization without writing a full program.

Why use an AWK online compiler?

AWK is available on basically every Unix system, so why run it in a browser? A few reasons:

  • You're on a Windows machine or a Chromebook without a terminal handy
  • You want to iterate on an AWK script with sample input data side by side
  • You're teaching someone AWK and want a shareable link they can run immediately

Field processing example

Here's a practical AWK program that processes tab-separated data:

BEGIN {
    FS = ","
    printf "%-12s %-8s %s\n", "Name", "Score", "Grade"
    printf "%-12s %-8s %s\n", "----", "-----", "-----"
}
{
    name = $1
    score = $2

    if (score >= 90) grade = "A"
    else if (score >= 80) grade = "B"
    else if (score >= 70) grade = "C"
    else grade = "F"

    printf "%-12s %-8d %s\n", name, score, grade
    total += score
    count++
}
END {
    printf "\nAverage score: %.1f\n", total/count
}

Feed it input like:

Alice,95
Bob,82
Charlie,71
Diana,88

The BEGIN block runs once before any input. The middle block runs for every line, with $1 and $2 giving you the fields split by the comma separator. The END block runs after all input is processed. This pattern-action structure is what makes AWK so effective for data pipelines.

AWK on OneCompiler

OneCompiler lets you provide both the AWK program and the input data, then run them together. This is exactly how AWK is meant to be used -- program plus data. It's a fast way to prototype AWK scripts before dropping them into a shell pipeline.

Try it: AWK Online Compiler on OneCompiler