= 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 [[Linux/Hosts|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 [[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]] ---- == Syntax == * [[Awk/Patterns|Patterns]] * [[Awk/Actions|Actions]] ---- == See also == [[https://man.archlinux.org/man/awk.1p|awk(1p)]] [[https://www.gnu.org/software/gawk/manual/gawk.html|GNU awk user manual]] ---- CategoryRicottone