Differences between revisions 5 and 7 (spanning 2 versions)
Revision 5 as of 2022-09-27 01:32:36
Size: 1108
Comment:
Revision 7 as of 2023-04-03 12:55:06
Size: 1218
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
'''`awk(1)`''' is a scripting language designed for text processing.

There are several implementation of '''`awk(1)`''':

 * Brian Kernighan [[https://github.com/onetrueawk/awk|open-sourced]] the original Unix implementation
 * '''GNU awk''' (or '''gawk''') is an extended implementation
 * [[BusyBox]] implements POSIX `awk(1)`
 * the modern revivalist [[https://github.com/benhoyt/goawk|GoAWK]]

See the [[https://www.gnu.org/software/gawk/manual/gawk.html|GNU awk User Manual]] for further documentation.
'''`awk(1p)`''' is a scripting language designed for text processing.
Line 26: Line 17:
A better example is extracting the hostnames from the [[Linux/hosts|hosts file]]. A more realistic example is extracting hostnames from the [[Linux/hosts|hosts file]].
Line 32: Line 23:
The awk syntax can be written to a script file and executed like: Execute a script as:
Line 42: Line 33:
To make an awk script executable, use `#! /bin/awk -f` as the shebang line. To make an `awk(1p)` script executable, use `#! /bin/awk -f` as the shebang line.

----



== Installation ==

`awk(1p)` will be installed on all [[Linux]] or [[BSD]] distributions.

There are several implementations, some of which are available on additional platforms.

 * Brian Kernighan [[https://github.com/onetrueawk/awk|open-sourced]] the original Unix implementation
 * '''GNU awk''' (or '''gawk''') is an extended implementation
 * [[BusyBox]]
 * [[https://github.com/benhoyt/goawk|GoAWK]]
Line 53: Line 59:
----



== See also ==

[[https://man.archlinux.org/man/awk.1p|awk(1p)]]

[[https://www.gnu.org/software/gawk/manual/gawk.html|GNU awk user manual]]

Awk

awk(1p) is a scripting language designed for text processing.


Example

awk 'BEGIN { print "hello world" }'

A more realistic example is extracting hostnames from the hosts file.

awk '/^[^#]/ { print $2 }' /etc/hosts

Execute a script as:

awk -f my-hosts-parser.awk /etc/hosts

Shebang

To make an awk(1p) script executable, use #! /bin/awk -f as the shebang line.


Installation

awk(1p) will be installed on all Linux or BSD distributions.

There are several implementations, some of which are available on additional platforms.

  • Brian Kernighan open-sourced the original Unix implementation

  • GNU awk (or gawk) is an extended implementation

  • BusyBox

  • GoAWK


Syntax


See also

awk(1p)

GNU awk user manual


CategoryRicottone

Awk (last edited 2023-06-22 20:03:20 by DominicRicottone)