(awk) – is a Unix/Linux utility used to perform simple text-processing tasks, but when combined with our scripting tools, it can be powerful to perform complex text-processing tasks to a level of a full programming language.
The ” awk” text-processing language is useful for tasks such as:
- – Tallying information from text files and creating reports from the
results.
- – Adding additional functions to text editors like “vi”.
- – Translating files from one format to another.
- – Creating small databases.
- – Performing mathematical operations on files of numeric data.
How does “awk” work?
• awk reads the file being processed line by line.
• The entire content of each line is split into columns with
space or tab as the delimiter.
• $0 Print the entire line
• $1, $2, $3, … for each column (if exists)
• NR number of records (lines)
• NF number of fields or columns in the current line.
• By default the field delimiter is space or tab. To change the field delimiter use the -F<delimiter> command.