Home

gawk

gawk is the GNU implementation of the AWK programming language, a domain-specific tool for pattern scanning and text processing. Like other AWK variants, it reads input line by line, splits each line into fields, and executes actions based on pattern matches. Gawk is part of the GNU project and is distributed under the GNU General Public License.

Compared with other AWK implementations, gawk adds extensions and enhancements that remain compatible with POSIX AWK.

Usage examples illustrate its typical role: gawk -F: '/root/ {print $1}' /etc/passwd prints usernames with a root

gawk is widely available on Linux, macOS, BSD, and other Unix-like systems and can also run on

It
provides
associative
arrays,
a
broader
set
of
built-in
functions,
and
extensive
string
and
data-processing
facilities.
It
also
includes
advanced
features
such
as
asort
and
asorti
for
sorting
associative
arrays,
gensub
for
flexible
regular-expression
substitution,
and
the
ability
to
read
and
execute
programs
from
files.
In
addition,
gawk
accepts
a
range
of
command-line
options
to
control
behavior,
including
-F
to
set
the
input
field
separator
and
-v
to
define
variables,
and
-W
posix
to
request
strict
POSIX
compatibility.
In
newer
versions,
gawk
supports
in-place
editing
of
files
with
the
-i
option.
field;
gawk
-v
min=10
'NR
>
min
{print
NR
":"
$0}'
file
prints
lines
after
a
given
line
number.
gawk
programs
can
be
written
inline
as
one-liners
or
saved
in
script
files
and
executed
with
the
-f
option.
Windows
through
environments
such
as
Cygwin
or
MSYS2.
It
is
a
free
software
project
and
its
source
code
and
binaries
are
distributed
under
the
GNU
General
Public
License,
ensuring
access
to
the
source
and
the
ability
to
modify
and
share.