Modern QA2026awk and sed (Quick Reference) — tiles
Log inJoin
21 / 55 · 19 Linux & Command Line · grep, curl, and jq← prev⊞ allnext →☰ Read as one page

3.6awk and sed (Quick Reference)

Two additional text processing tools that complement grep:

# awk: Calculate average response time from a log
awk '{sum += $4; count++} END {print sum/count "ms"}' response-times.log

# awk: Print specific columns
awk '{print $1, $4, $7}' /var/log/nginx/access.log

# sed: Replace staging URL with production URL
sed 's/staging.example.com/prod.example.com/g' test-config.json

# sed: Delete lines matching a pattern
sed '/healthcheck/d' application.log

# sed: Insert text at the beginning of a file
sed -i '1i # This is a test configuration file' config.json