Docs / Linux Basics / How to Use the awk Text Processing Tool

How to Use the awk Text Processing Tool

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 502 views · 1 min read

awk is a powerful tool for processing structured text data.

Print Columns

# Print first column\nawk '{print $1}' file.txt\n\n# Print first and third columns\nawk '{print $1, $3}' file.txt

With Delimiter

# CSV with comma delimiter\nawk -F',' '{print $1, $3}' data.csv\n\n# Colon delimiter (e.g., /etc/passwd)\nawk -F':' '{print $1, $6}' /etc/passwd

Filtering

# Lines where column 3 > 100\nawk '$3 > 100' file.txt\n\n# Lines matching pattern\nawk '/error/' logfile

Summing

awk '{sum += $1} END {print sum}' numbers.txt

Was this article helpful?