A short companion for sed Replacement Builder: when it is useful, what it expects, and what to check before using the result.

What it does

Build the sed command you would otherwise look up again. Choose between a substitution, deleting matching lines or printing only the matches, then set the regex style, the delimiter and the flags. The page escapes the delimiter inside the pattern and quotes the whole expression, so a copy-paste into the shell behaves the same way it did here.

Use the tool

Open sed Replacement Builder, add the input the tool asks for, run it, and check the output before using it elsewhere.

Input and output

  • Input: text.
  • Output: text.
  • Category: Text.

Privacy and processing

Processing happens locally in your browser. This tool does not upload the input to ilham.dev.

Questions

Is an in-place edit reversible?

Only with the backup. With -i.bak on, sed leaves the original next to the file with a .bak suffix; turn the backup off and there is no undo.

What does the I flag do?

It makes the pattern match without regard to case. It is a GNU extension, so it works with GNU sed on Linux but not with the old BSD sed on macOS.

Why does it quote the expression in single quotes?

A sed expression is full of characters the shell would otherwise interpret, like spaces, pipes, stars and dollar signs. Single quotes hand the whole expression to sed untouched.

Related guide

For broader background, see Linux Command Line Tasks Without Surprises.