Home Explore Blog CI



man-pages

1st chunk of `awk.man`
80235ff5523d6028eae0a316d86318ced34222f11c93b0d90000000100000fd2
MAWK(1)                                                                                                   User commands                                                                                                  MAWK(1)

NAME
       mawk - pattern scanning and text processing language

SYNOPSIS
       mawk [-W option] [-F value] [-v var=value] [--] ’program text’ [file ...]
       mawk [-W option] [-F value] [-v var=value] [-f program‐file] [--] [file ...]

DESCRIPTION
       mawk is an interpreter for the AWK Programming Language.  The AWK language is useful for manipulation of data files, text retrieval and processing, and for prototyping and experimenting with algorithms.  mawk is a new
       awk  meaning  it  implements  the  AWK language as defined in Aho, Kernighan and Weinberger, The AWK Programming Language, Addison‐Wesley Publishing, 1988 (hereafter referred to as the AWK book.)  mawk conforms to the
       POSIX 1003.2 (draft 11.3) definition of the AWK language which contains a few features not described in the AWK book, and mawk provides a small number of extensions.

       An AWK program is a sequence of pattern {action} pairs and function definitions.  Short programs are entered on the command line usually enclosed in ’ ’ to avoid shell interpretation.  Longer programs can be  read  in
       from  a  file  with the -f option.  Data  input is read from the list of files on the command line or from standard input when the list is empty.  The input is broken into records as determined by the record separator
       variable, RS.  Initially, RS = “\n” and records are synonymous with lines.  Each record is compared against each pattern and if it matches, the program text for {action} is executed.

OPTIONS
       -F value       sets the field separator, FS, to value.

       -f file        Program text is read from file instead of from the command line.  Multiple -f options are allowed.

       -v var=value   assigns value to program variable var.

       --             indicates the unambiguous end of options.

       The above options will be available with any POSIX compatible implementation of AWK.  Implementation specific options are prefaced with -W.  mawk provides these:

       -W dump
              writes an assembler like listing of the internal representation of the program to stdout and exits 0 (on successful compilation).

       -W exec file
              Program text is read from file and this is the last option.

              This is a useful alternative to -f on systems that support the #!  “magic number” convention for executable scripts.  Those implicitly pass the pathname of the script itself as the final parameter,  and  expect
              no more than one “-” option on the #! line.  Because mawk can combine multiple -W options separated by commas, you can use this option when an additional -W option is needed.

       -W help
              prints a usage message to stderr and exits (same as “-W usage”).

       -W interactive
              sets unbuffered writes to stdout and line buffered reads from stdin.  Records from stdin are lines regardless of the value of RS.

       -W posix
              modifies mawk’s behavior to be more POSIX‐compliant:

              •   forces mawk not to consider ’\n’ to be space.

              The original “posix_space” is recognized, but deprecated.

       -W random=num
              calls srand with the given parameter (and overrides the auto‐seeding behavior).

       -W sprintf=num
              adjusts the size of mawk’s internal sprintf buffer to num bytes.  More than rare use of this option indicates mawk should be recompiled.

       -W traditional
              Omit features such as interval expressions which were not supported by traditional awk.

       -W usage
              prints a usage message to stderr and exits (same as “-W help”).

       -W version
              mawk writes its version and copyright to stdout and compiled limits to

Title: MAWK - Pattern Scanning and Text Processing Language
Summary
This document describes `mawk`, an interpreter for the AWK programming language. AWK is designed for data file manipulation, text retrieval, and algorithm prototyping. The document covers the syntax, options, and POSIX compliance of `mawk`, including options for setting field separators, reading program files, assigning variables, and controlling behavior related to POSIX standards and buffer sizes.