If grep is the scout that finds the material, sed is the hammer and chisel that reshapes it. It is a non-interactive stream editor, meaning it transforms text as it flows through the pipeline—no opening files, no manual cursor movement.
The Basic Strike: Substitution
The most common use of sed is the s command. It’s the ultimate “Find and Replace” for the terminal:
# Change "Zola" to "Hugo" across an entire draft
sed 's/Zola/Hugo/g' draft.md
Surgical Precision: Line-Specific Editing
A Textsmith doesn’t always want to hit the whole piece of steel. sed can target specific lines:
# Delete only the first 5 lines of a log (the header) before processing
sed '1,5d' system.log
Why it’s a Trinity Core
sed is the bridge. It cleans the data found by grep so that it is perfectly formatted for the complex logic of awk.
Forged in the terminal. Refined under the anvil.