AWK Basics — Pattern Scanning and Text Processing in Linux

awk is a pattern-scanning and text-processing language, commonly used for extracting and reformatting columns of data.

Published September 30, 2026

awk is a pattern-scanning and text-processing language, commonly used for extracting and reformatting columns of data.

Key points

  • awk automatically splits each input line into fields, accessed as $1, $2, and so on, with $0 meaning the whole line
  • awk '{print $1}' file.txt prints just the first column of every line
  • Supports conditions and patterns, e.g. awk '$3 > 100 {print $1}' to filter rows by a numeric field

Example

awk '{print $1, $3}' access.log
More Linux articles