Skip to content
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN DE
Let's talk

Sed and Awk — A Practical Tutorial

05. 04. 2025 Updated: 24. 03. 2026 1 min read intermediate

Sed and awk are the most powerful text processing tools on the command line. Sed excels at substitution, awk at extraction and analysis of structured data.

Sed — Stream Editor

sed ‘s/foo/bar/g’ soubor.txt sed -i ‘s/foo/bar/g’ soubor.txt sed ‘/^#/d’ config.conf sed ‘/^$/d’ soubor.txt sed -n ‘/BEGIN/,/END/p’ soubor.txt

Awk — Pattern Scanning

awk ‘{print $1, $3}’ soubor.txt awk ‘$3 > 100 {print $1, $3}’ data.txt awk -F’:’ ‘{print $1, $7}’ /etc/passwd awk ‘{sum += $2} END {print sum}’ data.txt awk ‘{count[$1]++} END {for (k in count) print k, count[k]}’ access.log

Practical Examples

awk ‘{print $1}’ access.log | sort | uniq -c | sort -rn | head awk ‘{print $9}’ access.log | sort | uniq -c | sort -rn awk -F’,’ ‘$3 > 1000 {print $0}’ sales.csv awk -F’:’ ‘$3 >= 1000 {print $1}’ /etc/passwd

When to Use Which

  • Sed — substitution, deleting lines, in-place editing
  • Awk — columns, calculations, aggregation
  • Combination — sed for preprocessing, awk for analysis

Indispensable

Investing in sed and awk pays off many times over when working with logs and data.

sedawklinuxtext processing
Share:

CORE SYSTEMS team

We build core systems and AI agents that keep operations running. 15 years of experience with enterprise IT.