# sed Replacement Builder

Build a sed command to replace text, delete matching lines or print only matches, with in-place editing and backups.

- Category: Text (text)
- URL: https://ilham.dev/tools/sed-replacement-builder/
- Documentation: https://ilham.dev/tools/sed-replacement-builder/index.md
- Keywords: sed, replace, substitute, regex, command, builder, in-place, stream, editor, text, shell

## Example questions

- Is an in-place edit reversible?
- What does the I flag do?
- Why does it quote the expression in single quotes?

## Properties

- Runs in the browser
- No login required
- No data uploaded


## About

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.


## 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.

