====== AWK - About AWK ======
**AWK** is a programming-language tool used to manipulate text.
It allows you to create short programs that read input files, sort data, process it, perform arithmetic on the input, and generate reports, among myriad other functions.
The language of the AWK utility resembles the shell-programming language in many areas, although AWK’s syntax is very much its own.
When first created, AWK was designed to work in the text-processing arena, and the language is based on executing a series of instructions whenever a pattern is matched in the input data.
* The utility scans each line of a file, looking for patterns that match those given on the command line.
* If a match is found, it takes the next programming step. If no match is found, it then proceeds to the next line.
----
===== AWK Syntax =====
The general syntax for the command is:
awk '{pattern + action}' {filenames}
* **pattern** represents what AWK is looking for in the data.
* **action** is a series of commands executed when a match is found.
**NOTE:** Curly brackets ({}) are not always required around your program, but they are used to group a series of instructions based on a specific pattern.
----
===== AWK Workflow =====
AWK follows a simple workflow − Read, Execute, and Repeat.
{{:awk:awk_-_workflow.png?600|}}
* **Read** - AWK reads a line from the input stream (file, pipe, or stdin) and stores it in memory.
* **Execute** - All AWK commands are applied sequentially on the input. By default AWK execute commands on every line. We can restrict this by providing patterns.
* **Repeat** - This process repeats until the file reaches its end.