In the world of the Unix Shell, we often speak of the Trinity: Grep, Sed, and Awk. While Grep is our scout and Awk is our processor, Sed (the Stream Editor) is our transformer.

If you have ever found yourself opening fifty different Markdown files in Vim just to change a single URL or fix a recurring typo, you are working too hard. In this post, we’re looking at how to use sed to perform bulk replacements across an entire project in seconds.

The Manual Labor Trap

Manual editing is the enemy of efficiency. It’s slow, it’s boring, and it’s where human error thrives. When you use a stream editor, you aren’t “opening” files in the traditional sense. You are creating a filter that text passes through. The text goes in “old,” and it comes out “new.”

The Magic of In-Place Editing

The most powerful weapon in the sed arsenal for a blogger is the -i (in-place) flag. This tells sed to write the changes directly back to the file instead of just printing them to your terminal.

Here is the “holy grail” command for bulk replacement:

sed -i 's/old-text/new-text/g' *.md

Let’s break down the spell:

  • s: Stands for “substitute.”
  • old-text: The string or regular expression you want to find.
  • new-text: What you want to replace it with.
  • g: Stands for “global.” Without this, sed only replaces the first instance it finds on each line.
  • -i: The magic wand that saves the changes to the file.

Safety First: The “Dry Run”

Because sed -i is so powerful, it can be dangerous. If your regular expression is slightly off, you could accidentally scramble your entire directory.

Before I commit to the change, I always run a “dry run” by omitting the -i. This prints the result to the terminal so I can verify the logic:


sed 's/labor/labour/g' post.md | less

Alternatively, you can tell sed to create a backup of the original file just in case:


sed -i.bak 's/old/new/g' *.md

This creates a .md.bak copy of every file before it touches the original.

Why it Matters

Using the Trinity isn’t just about saving time; it’s about digital sovereignty. When you master tools like sed, you aren’t dependent on heavy, bloated software to manage your data. You have the power to reshape your entire digital workspace with a single line of code.

Stop clicking. Start streaming.


Forged in the terminal. Refined under the anvil.