|
Size: 1218
Comment:
|
← Revision 8 as of 2023-06-22 20:03:20 ⇥
Size: 1218
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 17: | Line 17: |
| A more realistic example is extracting hostnames from the [[Linux/hosts|hosts file]]. | A more realistic example is extracting hostnames from the [[Linux/Hosts|hosts file]]. |
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/hostsExecute 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
Syntax
