Use Sed Command Generator

Enter your data below to use the Sed Command Generator

📌 Try these examples:
RESULT

Last updated

GNU sed vs BSD sed (macOS) Differences

Common Use Cases

Examples

Example 1: Basic Substitution

Replace the first occurrence of a word on each line:

sed 's/foo/bar/' file.txt

Replace all occurrences on each line (global flag):

sed 's/foo/bar/g' file.txt

Case-insensitive replacement (GNU sed):

sed 's/foo/bar/gi' file.txt

Replace and edit the file in place (GNU sed):

sed -i 's/foo/bar/g' file.txt

In-place edit with backup (macOS/BSD sed):

sed -i '.bak' 's/foo/bar/g' file.txt

Example 2: Delete Lines

Delete blank lines:

sed '/^$/d' file.txt

Delete lines containing a specific pattern:

sed '/TODO/d' file.txt

Delete comment lines starting with #:

sed '/^#/d' file.txt

Delete a specific line number (line 5):

sed '5d' file.txt

Delete a range of lines (lines 3 through 7):

sed '3,7d' file.txt

Delete from a pattern to end of file:

sed '/^END/,$d' file.txt

Example 3: Print Specific Lines

Print only lines matching a pattern (like grep):

sed -n '/error/p' file.txt

Print lines 10 through 20:

sed -n '10,20p' file.txt

Print from a pattern to another pattern:

sed -n '/START/,/END/p' file.txt

Frequently Asked Questions

Simply enter your data, click the process button, and get instant results. All processing happens in your browser for maximum privacy and security.

Yes! Sed Command Generator is completely free to use with no registration required. All processing is done client-side in your browser.

Absolutely! All processing happens locally in your browser. Your data never leaves your device, ensuring complete privacy and security.