On this Page
Jawk 7.1.01
-
Home
- Jawk CLI
CLI Reference
This page documents every option accepted by the jawk CLI[1].
Caution
The precompiled programs written by -K and loaded with -L, and the state files used by --persist, rely on Java serialization and are tied to the Jawk version that produced them. When Jawk reports that such a file is incompatible, recompile or discard it instead of trying to reuse it.
Invocation Shape
The common command shape is:
jawk [options] [--] [script] [name=value | input_filename | -]...
jawk is the launcher set up by the one-command install[2]; java -jar jawk-7.1.01-standalone.jar accepts exactly the same arguments.
The extension listing and version reporting modes are separate:
jawk --list-ext
jawk --version
Option Groups
scriptis the inline AWK program used when you do not pass-for-L.-f <filename>reads a script from a file. You can repeat-fto combine multiple script sources.-L <filename>loads a program previously compiled with-Kinstead of compiling source now.--persist <filename>loads retained user-defined globals from a state file before execution and writes them back after the run finishes. TheJAWK_PERSISTENT_MEMORYenvironment variable can point at the same file;--persistwins when both are present.-K <filename>compiles the current script sources to a program file and exits without executing the script.
ARGV--marks the end of options (POSIX): every following argument is the script (when-for-Lwas not used) and its operands.- Remaining operands after the script are exposed through
ARGVandARGC. - An operand without
=is treated as an input filename. - The
-operand designates standard input as an input file (POSIX).FILENAMEis-while it is being read. - An operand containing
=is treated as an AWK-style file-list assignment that applies before the next input file is consumed. - Use
-v name=valueinstead when the variable must exist beforeBEGIN. - As in gawk, once the program text has been supplied (with
-for-L), an unknown option ends option processing and is passed on to the AWK program throughARGV, which is useful for#!interpreter scripts. - The value of a value-taking short option may be attached to the option letter (POSIX/getopt style):
-fprog.awk,-vx=1, and-F:are equivalent to-f prog.awk,-v x=1, and-F :. This applies to-f,-v,-F,-L,-K, and-l.
-v <name=value>assigns a variable before execution begins.-F <fs>sets the initial field separator.--locale <locale>sets the locale used to format numbers, throughLocale.forLanguageTag(...).-tkeeps associative array keys sorted.--posixenforces POSIX-oriented compile-time behavior such as disabling gawk-style nested arrays, all gawk@forms, and theBEGINFILE/ENDFILEspecial patterns.
-l <extension>or--load <extension>loads an extension by registered identifier, simple class name, or fully qualified class name; a class that is not registered yet resolves by its fully qualified class name only, and must be on the JVM classpath (setJAWK_CLASSPATHwhen using thejawklauncher). Passing-lreplaces the default extension set (the gawk compatibility extension), so add-l GawkExtensionwhen the script still needs the gawk builtins.--list-extprints the identifiers currently registered inExtensionRegistryand exits. It must be used by itself.-Sor--sandboxcompiles and runs the script with sandbox restrictions enabled.
--dump-syntaxprints the parsed abstract syntax tree and skips execution.--dump-intermediateprints the tuple stream and skips execution.-sor--no-optimizedisables tuple optimization during compilation.--profileexecutes the script with runtime profiling enabled and prints tuple and function timing statistics to stderr.--profile=<filename>writes the same profiling report to the specified file instead of stderr.
-hand-?print usage and exit. They must be used by themselves.-Vand--versionprint the Jawk version and the Java runtime that executes it, then exit. They must be used by themselves.- Usage output names the command Jawk was invoked as: the installed
jawklauncher passes its invocation name through theJAWK_PROGRAM_NAMEenvironment variable, and without that variable the output falls back to the directjava -jar <jar>form. - Missing option arguments, invalid
-vsyntax, or missing scripts cause argument parsing to fail. An unknown option is rejected only when no program text has been supplied yet; otherwise it flows toARGVas described above. - A run that fails reports the problem on standard error and exits with a non-zero status.
Execution Notes
--dump-syntax,--dump-intermediate,-K,-h,-?,-V,--version, and--list-extdo not execute the script, and ignore an ambientJAWK_PERSISTENT_MEMORY.--dump-syntax,--dump-intermediate, and-Kalso ignore--persist, while the standalone modes (-h,-?,-V,--version,--list-ext) reject it like any other extra argument.--profiledoes execute the script, and keeps the normal AWK output on stdout.-fcompiles source now,-Lloads a program compiled earlier.--posixis rejected together with-L: loading a precompiled program bypasses source compilation, so there is no compile-time behavior left to restrict.-Sapplies at compile time as well as at run time — a sandboxed run rejects the forbidden constructs while compiling the script.
See Also
cli
options
flags
command line
awk
Links:
- [1] apidocs/io/jawk/Cli.html
- [2] install.html
- [3] cli.html
- [4] java.html
- [5] compatibility.html
Search Results for {{siteSearch | truncate:'50'}}
{{resultArray.length}}
Searching...
No results.
