Jawk 7.1.01
- Getting Started Overview Installation
- Jawk Java API Java Quickstart Structured Input Variables and Arguments Custom Output Compile, Eval, and Reuse Advanced Runtime
- Jawk CLI CLI Quickstart CLI Reference
- Extensions Using Extensions Writing Extensions
- Reference Compatibility and Compliance Behavior Changes Performance Benchmarks Javadoc (API)
- Project Documentation Project Information 9 Project Reports 9
Jawk: AWK for Java
Overview
Jawk is a pure Java implementation of AWK[1]. You can run AWK programs in a JVM application and integrate with your Java code:
CLI
$ echo "hello world" | jawk '{ print $2 ", " $1 "!" }'
world, hello!
Java
Awk awk = new Awk();
String result = awk.script("{ print toupper($0) }").input("hello world").execute();
// result = "HELLO WORLD\n"
Compatibility and Compliance
POSIX
One True Awk
gawk
The above scores are calculated from the latest compatibility tests during mvn verify site. See the full compatibility dashboard[2] for per-suite maps and the Failsafe report[3] for detailed test results.
Key Capabilities
- A drop-in AWK command line: inline scripts, script files,
name=valueoperands, and input files - Java entry points to run a whole script, evaluate a single expression, or compile either one once and reuse it
- Structured input through
InputSource, to feed rows or already-tokenized fields straight from your own data structures - Custom output through
AwkSink, to collect what a script prints as Java values instead of text - Gawk builtins enabled by default:
asort(),asorti(),typeof(),isarray(),mkbool(),gensub(),patsplit(),strtonum(),systime(),mktime(),strftime(), the gettext functions, andPROCINFO["sorted_in"] - Java extensions, loaded from the CLI or the Java API, to expose your own functions to a script
- A sandboxed mode, in Java and on the CLI, that rejects
system(), redirections, pipes, and@include - Precompilation:
-Kwrites a compiled program to a file,-Lruns it later without parsing the source again
Differences with Traditional AWK
Jawk aims to be a practical AWK implementation for JVM environments, but it is not a byte-for-byte clone of every historical AWK behavior. Some differences are deliberate and come from the way Jawk integrates with Java:
- Regular expression behavior follows Java's regex engine, which may differ from traditional AWK regexes in edge cases. Notably, alternation picks the first matching branch rather than the POSIX longest one, which can affect
match(), field splitting withpatsplit(), and similar content-driven matching: order alternatives longest-first. printf()andsprintf()implement the POSIX AWK conversions with gawk's semantics, includingCONVFMT-based%sconversion, dynamic*width and precision, and gawk's out-of-range integer handling; only a few edge cases (%anotation,%clocale independence, the sign of NaN) follow Java's platform rules.- Some floating-point edge cases may differ due to Java's handling of floating-point arithmetic and representation.
- Where AWK ignores whitespace around numbers — the leading whitespace in string-to-number conversion, and the leading and trailing blanks that POSIX lets a numeric string carry — Jawk applies Java's whitespace definition (
Character.isWhitespace), which also covers Unicode spaces such as U+2003; C-based implementations only skip the C locale's narrowerisspaceset. - The date and time functions (
mktime(),strftime()) follow the Java platform's time zone data and calendar rules rather than the C library's, which differs from gawk in a few edge cases.
The Compatibility[2] page details these edge cases, along with the places where Jawk deliberately follows gawk rather than historical AWK, and the live compatibility reports.
History of Jawk
| Date | Event |
|---|---|
| 2006-02-26 | Initial release of Jawk 0.1 on SourceForge[4] by Danny Daglas[5], the original author of this project. |
| 2008-01-18 | Last release of Jawk 1.02 on SourceForge, corresponding to the official (now defunct) Jawk website[6]. |
| 2012-07-18 | Fork on GitHub[7] by hoijui[8] (a.k.a. Robin Vodruba), with the first commit being a copy of the original Jawk 1.02 source code + Maven. |
| 2018-02-06 | Bertrand Martin begins maintaining a private fork at Sentry Software[9] with a first private release of Jawk 1.03. |
| 2023-07-20 | Bertrand's fork is finally made public on Sentry Software's GitHub repository. Jawk is in version 2.1.xx. |
| 2023-12-14 | Jawk 3.0.00 is released on Maven Central[10] under org.sentrysoftware.jawk. |
| 2025-02-13 | Version 3.3.04[11] is the last version of Jawk released by Sentry Software. MetricsHub[12] takes over the project. |
| 2025-11-04 | MetricsHub releases Jawk 5.0.00[13] on Maven Central. |
| 2026-03-26 | Bertrand Martin moves Jawk to an independent jawkio/jawk GitHub repository[14], dedicated to Jawk only. |
| 2026-04-16 | Version 6.0.00 of Jawk is released on Maven Central[15] under io.jawk. The project is now hosted at jawk.io[16]. |
Next Steps
- Install Jawk[17]
- Learn the CLI[18]
- Embed Jawk in Java[19]
- Load or write extensions[20]
jawk
awk
java
cli
text processing
awk
Links:
- [1] https://en.wikipedia.org/wiki/AWK
- [2] compatibility.html
- [3] failsafe.html
- [4] https://sourceforge.net/projects/jawk/files/jawk/0.1/
- [5] https://sourceforge.net/u/ddaglas/profile/
- [6] https://web.archive.org/web/20260209081949/https://jawk.sourceforge.net/
- [7] https://github.com/hoijui/Jawk
- [8] https://github.com/hoijui
- [9] https://www.sentrysoftware.com/
- [10] https://central.sonatype.com/artifact/org.sentrysoftware/jawk/3.0.00
- [11] https://central.sonatype.com/artifact/org.sentrysoftware/jawk/3.3.04
- [12] https://metricshub.com
- [13] https://central.sonatype.com/artifact/org.metricshub/jawk/5.0.00
- [14] https://github.com/jawkio/jawk
- [15] https://central.sonatype.com/artifact/io.jawk/jawk/6.0.00
- [16] https://jawk.io
- [17] install.html
- [18] cli.html
- [19] java.html
- [20] extensions.html
Search Results for {{siteSearch | truncate:'50'}}
{{resultArray.length}}
Searching...
No results.
