---
description: Quickstart guide for running Jawk from the command line.
date_published: 2026-05-13
date_modified: 2026-05-13
canonical_url: https://jawk.io/cli.html
---

# Jawk CLI Quickstart

On this Page

- [Run an Inline Script](#run-an-inline-script)
- [Run a Script File](#run-a-script-file)
- [Read from stdin](#read-from-stdin)
- [Read Input Files](#read-input-files)
- [Pass Variables](#pass-variables)
- [Load Extensions](#load-extensions)
- [Enable Sandbox Mode](#enable-sandbox-mode)
- [See Also](#see-also)

Jawk CLI behaves like AWK, but runs entirely on the JVM. You can pass an inline program, read a script from a file, feed input through standard input or filenames, assign variables, load explicit extensions, dump syntax or tuples, precompile tuples, and switch to a sandboxed runtime when needed.

** Warning

Shell quoting differs by platform. The examples below use separate command forms where quoting is meaningfully different. If a script works in one shell but not another, the quoting is usually the first thing to check.

## [Run an Inline Script](#run-an-inline-script)

Linux/UNIX

**Linux/UNIX**

```shell-session
$ echo "hello world" | java -jar jawk-6.4.00-standalone.jar '{ print $2 ", " $1 "!" }'
world, hello!
```

Windows

**Windows**

```shell-session
C:\> echo hello world | java -jar jawk-6.4.00-standalone.jar "{ print $2 "", "" $1 ""!"" }"
world, hello!
```

If you do not pass `-f` or `-L`, Jawk expects the next non-option argument to be the AWK program itself.

## [Run a Script File](#run-a-script-file)

Store the AWK program in a file:

**`totals.awk`**:

```awk
BEGIN {
  total = 0
}
{
  total += $2
}
END {
  print total
}
```

And point Jawk at it with `-f`:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar -f totals.awk values.txt
```

You can repeat `-f` to combine multiple script sources before execution.

## [Read from stdin](#read-from-stdin)

If you do not provide input filenames after the script, Jawk reads from standard input:

```shell-session
$ printf "alpha\nbeta\n" | java -jar jawk-6.4.00-standalone.jar '{ print NR ":" $0 }'
1:alpha
2:beta
```

## [Read Input Files](#read-input-files)

Input filenames passed after the script become runtime operands and are processed as AWK input files:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar -F : '{ print FILENAME ":" FNR ":" $1 }' /etc/passwd /etc/group
```

Jawk follows the usual AWK distinction between the script itself and the remaining operands. Files and `name=value` operands after the script are visible through `ARGV` and `ARGC`.

## [Pass Variables](#pass-variables)

Use `-v` for variables that must exist before `BEGIN` runs:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar -v prefix=hello 'BEGIN { print prefix }'
hello
```

Use `name=value` operands after the script for AWK-style file-list assignments that take effect before the next input file is consumed:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar '{ print mode ":" $0 }' mode=csv data.txt
```

Set the field separator with `-F` when you want Jawk to split text records differently:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar -F : '{ print $1 "," $6 }' /etc/passwd
```

Use `--posix` when you want POSIX-oriented compile-time behavior from the CLI. In particular, it disables gawk-style nested arrays, so classic multi-dimensional subscripts such as `a[i, j]` remain valid while `a[i][j]` is rejected:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar --posix 'BEGIN { a[1,2] = 42; print a[1,2] }'
42
```

Because `-L` loads an already compiled tuples file, Jawk rejects `--posix` together with `-L` instead of pretending that it can re-apply compile-time restrictions after the fact.

## [Load Extensions](#load-extensions)

List the currently registered extension identifiers:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar --list-ext
```

Then load one explicitly:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar -l stdin -f script.awk
```

Jawk accepts the registered extension name, the simple class name, or the fully qualified class name. Additional extension classes can be placed on the JVM classpath before launching Jawk.

## [Enable Sandbox Mode](#enable-sandbox-mode)

Use `-S` or `--sandbox` to switch to the sandboxed tuple compiler and runtime:

```shell-session
$ java -jar jawk-6.4.00-standalone.jar -S -f script.awk input.txt
```

Sandbox mode disables `system()`, input and output redirection, command pipelines, and related runtime features that are intentionally unsafe in a restricted host environment.

## [See Also](#see-also)

- [CLI Reference](cli-reference.html)[1] for the full list of options and flags
- [Java Quickstart](java.html)[2] if you want to embed AWK in a JVM application
- [Using Extensions](extensions.html)[3]
- [Compatibility and Differences](compatibility.html)[4]
