The AWK Command – Complete Guide

AWK is a Unix text-processing language for scanning structured text files line-by-line and performing actions on matching patterns.

It is commonly used for logs, CSV files, reports, and automation pipelines. Unix command line

Each line is split into fields: $1, $2, $3…
$0 represents the entire line.
Default delimiter: whitespace (FS variable).

Built-in variables:
  • NR – line number
  • NF – number of fields
  • FS – field separator
  • OFS – output separator
AWK logo

awk 'pattern { action }' file
Examples:
awk '{print $1}' file
awk -F, '{print $2}' data.csv
awk '$3 > 100 {print}' report.txt

BEGIN runs before input starts.
END runs after all lines processed.

awk 'BEGIN{print "Start"} {sum+=$2} END{print sum}' data.txt

Sum a column:
awk '{sum+=$2} END{print sum}' sales.txt
Filter logs:
awk '/error/ {print}' system.log
Top IP addresses:
awk '{print $1}' access.log | sort | uniq -c | sort -nr | head
Linux terminal

• Installed on every Unix/Linux system
• Extremely fast (written in C)
• No dependencies
• Perfect for shell automation
• Replaces many small scripts

AWK is often described as SQL for text files.
Quality, Reliability & Service
Thank You For Visiting
Brooks Computing Systems - Jacksonville
Visit https://bcs.archman.us