sed Replacement Builder
Build a sed command to replace text, delete matching lines or print only matches, with in-place editing and backups.
sed Replacement Builder
Command
In-place editing has no undo, so the backup stays on unless you turn it off. File names and globs are left as you typed them so the shell can expand them; quote a name yourself if it contains spaces.
History for this tool
The most recent data you entered in this tool, stored only in this browser.
Save what you type here, in this browser? Your work would go into this browser's local storage, so a refresh or a trip to another tool does not wipe it. You also get a short list of previous entries under the form, each one restorable with a click. Nothing is ever uploaded, and there is no account.
Being straight about the trade-off: anything kept there can be read by anyone who can use this browser profile, and by any script that later runs on this site. A tool page can hold a private key, a password or a signed token. Saving is convenient; it is not private.
About this tool
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.