Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Before data pipelines had frameworks, there was AWK. Designed at Bell Labs in 1977 by Aho, Weinberger, and Kernighan, it distilled record processing into one elegant idea: pattern { action } rules applied to every line of input. Nearly fifty years on, AWK is still specified by POSIX, installed on effectively every Unix system, and actively developed — GNU Awk (gawk) 5.3 is current, and Kernighan himself updated the classic 'one true awk' as recently as 2023-2024. It remains the quickest tool alive for column extraction, sums, and quick reports from logs or CSVs. On this page AWK runs against a live terminal: type input lines while the program executes and watch rules fire in real time.
BEGIN {
print "Type numbers one per line; type 'done' to finish."
}
/^done$/ { exit }
/^-?[0-9]+(\.[0-9]+)?$/ {
sum += $1
count++
if (count == 1 || $1 > max) max = $1
next
}
{ print "Not a number, skipping:", $0 }
END {
if (count > 0)
printf "Count: %d | Sum: %g | Mean: %g | Max: %g\n", count, sum, sum / count, max
else
print "No numbers entered."
}
AWK earns its keep in daily server work: pulling the fifth column from a log, summing bytes per IP, filtering CSV rows by a numeric threshold — jobs where Python feels heavy and cut feels weak. DevOps and SRE interviews regularly include an AWK one-liner, and Unix tools courses teach it alongside grep and sed as core text-processing literacy. Use this page to prototype a program against typed test lines before wiring it into a production pipeline, or to finally learn what NR, NF, and associative arrays actually do.
Just type it. AWK reads stdin when no file is given, and this terminal is interactive — every line you type is immediately run through your pattern-action rules, so matching output appears as you go. Signal end-of-input with a sentinel line your program checks (like 'done' with an exit rule).
A POSIX-compliant AWK, so everything in the standard works: BEGIN/END blocks, associative arrays, printf, split, gsub, getline, and user-defined functions. If you stick to POSIX features rather than gawk-only extensions (like gensub or ENVIRON tricks), your program will behave identically across gawk, mawk, and BSD awk.
Plain FS="," splitting breaks on quoted fields containing commas — that is a real AWK limitation. Gawk 5.3 added a --csv mode, but the portable approaches are preprocessing with a real CSV tool, using FPAT in gawk, or accepting simple comma-splitting for well-behaved data. For messy CSVs, Python's csv module is the safer choice.
main.awkplain text — no highlighter ships for this languagegetlineBEGIN {
print "Hello from AWK!"
print "Welcome to XCODX Online Compiler!"
}