sed Command Generator
Generate sed commands to filter and transform text streams
Getting Started with sed
## What is sed?
`sed` (stream editor) reads input line by line, applies a script of editing commands, and writes the result to standard output. It's ideal for find-and-replace, substitution, and bulk text transformations.
## How to Use
1. **Enter the Script**: Provide a `sed` expression such as `s/old/new/g`. 2. **Set Options** (optional): `-E` for extended regex, `-n` to suppress automatic printing, `-i` to edit files in-place. 3. **Specify File**: Enter the file to process. 4. **Copy & Run**: Copy the generated command into your terminal.
Substitution Syntax
The most common `sed` command is substitution:
``` s/pattern/replacement/flags ```
### Common flags - `g` — replace all occurrences on each line (not just the first) - `i` / `I` — case-insensitive match - `N` (a number) — replace only the Nth match - `p` — print the line only if a substitution was made (pair with `-n`)
### Examples - `s/foo/bar/g` — replace every `foo` with `bar` - `s/[0-9]+/N/g` (with `-E`) — replace each run of digits with `N` - `1d` — delete the first line - `/pattern/d` — delete lines matching `pattern`
### Quoting Always wrap the script in single quotes so the shell does not interpret `/`, `$`, or `\`. This generator handles the quoting for you.
▶What does the -i flag do?
▶How do I use special characters in my pattern?
If this tool has been helpful to you, consider buying me a coffee.
Buy me a coffee