RTFM · Tools
sed and awk: the classic pair
Two complementary stream editors: sed rewires text line-wise by substitution; awk treats fields as structured data. Together they replace most ad-hoc scripting temptations.

sed: substitute, delete, print selectively
Saphira ships sed supporting extended regular expressions via -E, plus the classic substitution and filtering verbs.
sed 's/old/new/' file # first occurrence per line
sed 's/old/new/g' file # every occurrence
sed -E 's/(\w+)@(\w+)/\2@\1/g' # extended regex + capture swap
sed -n '/ERROR/p' app.log # silent mode + explicit print
sed '/^#/d;/^$/d' config # strip comments and blanks
sed -i.bak 's/a/b/g' file # in-place with backup safety-i semantics vary between sed flavours regarding backup suffix handling; pass .bak explicitly or verify behaviour on a scratch copy first.
awk: fields, patterns, arithmetic
awk splits each line on whitespace into $1..$NF; the entire line is $0. That model alone covers most log-reduction tasks.
awk '{print $1}' access.log # first column
awk '$9 == 500 {print $7}' access.log # conditionally filter
awk -F: '{print $1, $3}' /etc/passwd # colon-delimited
awk '/error/ {count++} END {print count}' app.log # tally by pattern
awk '{sum+=$2} END {printf "%.1f MB\n", sum/1024}' sizes.txtThe END block runs after input ends — perfect place for totals. BEGIN handles pre-input setup. Between them lies the per-record body, conditionally gated by pattern expressions.
Choosing between them
| Task shape | Reach for |
|---|---|
| Search-replace textual pattern | sed |
| Extract/filter columns numerically | awk |
| Multi-step conditional transformations | awk |
| Simple global character cleanup | sed |
| Aggregations over delimited data | awk |
Learning both pays compound interest: outputs from one feed inputs of the other, chained through pipelines endlessly.
Prove it works: stream editor confidence
a one-liner written from scratch replaces a manual spreadsheet edit on a real log within five minutes.
Did we miss something?
If this page left something unanswered, found an error, or there is another subject you would like documented, tell us. Saphira’s documentation grows from real problems people need to solve.
Send feedback or request a new section →
Prefer not to do it yourself?
Everything needed to do the work yourself is documented here and remains free — we charge for human time, not for withholding knowledge. Sometimes the missing resource is simply time. The same people who build Saphira can provide paid professional help with implementation, migration, troubleshooting and administration.