LangStop
sed
Ready
Editor

Configuration

Stream editor for filtering and transforming text

Safety Advisory

`-i` with an empty suffix edits files destructively in place. Always provide a backup suffix (e.g. .bak) or test with dry-run first.

Required
Flags & Options

Add flags from the picker below...

Tests

-e
Script expression

Add the script to the commands to be executed (-e script). Can be repeated to chain multiple expressions.

-f
Script file

Read sed commands from the specified file (-f script-file). Can be repeated.

-i
In-place edit (with backup suffix)

Edit files in place. Optionally supply a suffix to create a backup (e.g. .bak). Use empty string for no backup — destructive! (-i[SUFFIX] / --in-place[=SUFFIX]).

-n
Suppress default output

Suppress automatic printing of pattern space; only print when explicitly told to via p command (-n / --quiet / --silent).

-r
Extended regex (GNU sed)

Use extended regular expressions (ERE) so that +, ?, |, {}, and () need not be escaped (-r / -E / --regexp-extended).

-E
Extended regex (POSIX)

Same as -r but uses the POSIX name (preferred for portability) (-E / --regexp-extended).

-s
Separate files

Treat each input file separately — line numbers reset and ranges apply independently per file (-s / --separate).

-u
Unbuffered

Load minimal amounts of data from the input files and flush output buffers more often (-u / --unbuffered). Useful for piped streams.

-z
NUL line separator

Separate lines by NUL characters (\0) instead of newlines (-z / --null-data). Useful with find -print0 or xargs -0.

--posix
POSIX compliance

Disable GNU sed extensions and run in strict POSIX mode (--posix).

-l
Line wrap length

Specify the default line-wrap length for the l command (-l N / --line-length=N). Default: 70.

--follow-symlinks
Follow symlinks (in-place)

Follow symlinks when editing in place (--follow-symlinks). Only meaningful with -i.

--sandbox
Sandbox mode

Disable e/r/w commands that can access the filesystem or execute shell commands (--sandbox).

--debug
Debug mode

Print the input sed script in canonical form and annotate execution (--debug). Useful for understanding complex scripts.

Live Output

Command
sed -

PRO TIP:Use -i.bak for safe in-place edits — always keep a backup until you're sure.

UTF-8
LangStop DevTools v1.0.0
;

SED Command Builder - Interactive Stream Editor Tool

Meta Information

Title Tag: SED Command Builder | Interactive Stream Editor Generator Meta Description: Build sed commands visually with our interactive generator. Create find-replace patterns, delete lines, insert text, and transform files without memorizing syntax. Free online sed tool. Keywords: sed command generator, sed find replace, sed stream editor, sed command builder, linux sed tutorial, sed regex patterns, sed substitute command, sed delete lines, sed in-place edit


Structured Data (JSON-LD)

{
  "@context": "https://schema.org",
  "@type": "WebApplication",
  "name": "SED Command Builder",
  "description": "Interactive visual builder for Linux sed stream editing commands",
  "applicationCategory": "DeveloperApplication",
  "operatingSystem": "Linux, macOS, Unix",
  "offers": {
    "@type": "Offer",
    "price": "0",
    "priceCurrency": "USD"
  },
  "featureList": [
    "Visual sed command generation",
    "Find and replace pattern builder",
    "Line deletion and insertion controls",
    "In-place editing options",
    "Regular expression support",
    "Address range selection"
  ]
}

Main Content

What is the SED Command?

The sed (Stream Editor) command is a powerful Unix utility for performing basic text transformations on an input stream [^27^]. It processes text line-by-line, making it ideal for automated text manipulation in shell scripts and system administration tasks.

Common Use Cases:

  • Find and replace text across files
  • Delete specific lines or patterns
  • Insert or append text at specific locations
  • Transform text case (uppercase/lowercase)
  • Extract specific lines from files
  • Batch process multiple files

Why Use This SED Command Builder?

Building sed commands requires understanding complex regex syntax and addressing. Our visual builder helps you:

  • ✅ Generate commands without syntax errors
  • ✅ Visualize pattern matching and replacement
  • ✅ Copy production-ready commands instantly
  • ✅ Learn stream editing through interactive examples

Core Features

1. Substitution Builder (s command)

Create find-and-replace operations with precision:

  • Global replacement (/g): Replace all occurrences per line [^26^]
  • Specific occurrence (/1, /2): Target nth match only [^26^]
  • Case insensitive (/I): Match regardless of case [^28^]
  • Custom delimiters: Use any character (|, #, @) to avoid escaping slashes
  • Capture groups: Save and reuse matched patterns with \1, \2 [^28^]

2. Line Addressing

Control which lines are affected:

  • Line numbers: Target specific lines (3d deletes line 3)
  • Line ranges: Apply to ranges (1,5 targets lines 1-5) [^26^]
  • Pattern matching: Use regex patterns (/pattern/)
  • Range patterns: Match from start to end pattern (/start/,/end/)
  • Inverted matches: Apply to lines NOT matching (!)

3. Text Manipulation Commands

Beyond substitution:

  • Delete (d): Remove lines matching criteria [^27^]
  • Insert (i): Add text before matching lines [^28^]
  • Append (a): Add text after matching lines [^28^]
  • Change (c): Replace entire lines [^28^]
  • Transform (y): Character-by-character translation
  • Print (p): Selectively output lines

4. File Processing Options

Control how files are handled:

  • In-place editing (-i): Modify files directly [^27^]
  • Backup creation (-i.bak): Save original with extension
  • Multiple commands (-e): Chain sed operations
  • Silent mode (-n): Suppress automatic printing [^26^]
  • Script files (-f): Execute commands from file

Common SED Command Patterns

Find and Replace

# Basic substitution (first occurrence only)
sed 's/foo/bar/' file.txt
 
# Global replacement (all occurrences)
sed 's/foo/bar/g' file.txt
 
# Replace on specific line only
sed '3 s/foo/bar/' file.txt
 
# Case insensitive replacement
sed 's/foo/bar/I' file.txt
 
# Replace 2nd occurrence only
sed 's/foo/bar/2' file.txt
 
# Replace from 2nd occurrence onward
sed 's/foo/bar/2g' file.txt

In-Place File Editing

# Edit file in place (no backup)
sed -i 's/foo/bar/g' file.txt
 
# Edit with backup
sed -i.bak 's/foo/bar/g' file.txt
 
# Edit multiple files
sed -i 's/foo/bar/g' *.txt

Line Deletion

# Delete specific line
sed '3d' file.txt
 
# Delete range of lines
sed '1,5d' file.txt
 
# Delete lines matching pattern
sed '/pattern/d' file.txt
 
# Delete empty lines
sed '/^$/d' file.txt
 
# Delete from pattern to end
sed '/pattern/,$d' file.txt

Selective Printing

# Print only matching lines (like grep)
sed -n '/pattern/p' file.txt
 
# Print lines 5-10
sed -n '5,10p' file.txt
 
# Print every 2nd line
sed -n '1~2p' file.txt

Insert and Append

# Insert before line 1
sed '1i\New first line' file.txt
 
# Append after line 5
sed '5a\New line after 5' file.txt
 
# Add after lines matching pattern
sed '/pattern/a\New line' file.txt

Advanced Transformations

# Convert to uppercase
sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' file.txt
 
# Replace tabs with spaces
sed 's/\t/    /g' file.txt
 
# Remove trailing whitespace
sed 's/[[:space:]]*$//' file.txt
 
# Add line numbers
sed '=' file.txt | sed 'N;s/\n/ /'

SED Command Reference

Substitution Syntax

sed 's/regexp/replacement/flags' filename

Flags:

Flag Description
g Global - replace all occurrences in line [^26^]
p Print line if substitution made
w file Write result to file
i or I Case insensitive match [^28^]
1-512 Replace only nth occurrence [^26^]
n-9g Replace from nth occurrence onward

Address Ranges

Address Meaning
3 Line number 3
3,5 Lines 3 through 5
3,$ Line 3 to end of file
/pattern/ Lines matching pattern
/start/,/end/ From start pattern to end pattern
3,/pattern/ From line 3 to pattern match
! Invert selection

Common Commands

Command Description
s Substitute (find/replace)
d Delete line [^27^]
p Print line [^28^]
i Insert text before line
a Append text after line
c Change (replace) line
y Transform characters
r Read file contents
w Write to file
q Quit processing
n Read next line
= Print line number

Options

Option Description
-i Edit files in place [^27^]
-i.suffix In-place with backup
-n Silent mode (no auto-print) [^26^]
-e Add script to commands
-f Read commands from file
-r Use extended regex
-E Extended regex (POSIX)

Understanding SED Regex

Special Characters

Pattern Matches
. Any single character
* Zero or more of preceding
+ One or more (extended regex)
? Zero or one (extended regex)
^ Start of line
$ End of line
[abc] Any character in set
[^abc] Any character NOT in set
( ) Capture group [^28^]
\1, \2 Backreference to group

Escape Sequences

Sequence Meaning
\n Newline
\t Tab
\r Carriage return
\ Literal backslash
/ Literal forward slash

FAQ

What is the difference between sed and grep?

grep searches for patterns and prints matching lines, while sed can edit and transform text streams [^27^]. Use grep for filtering, sed for text modification. Sed can duplicate grep functionality with sed -n '/pattern/p' [^28^].

How do I replace only the first occurrence per line?

By default, sed only replaces the first occurrence. Use /g flag to replace all, or /1 to explicitly target the first [^26^].

Can sed edit files in place?

Yes, use the -i flag: sed -i 's/foo/bar/g' file.txt. This modifies the file directly without creating a new copy [^27^].

How do I use different delimiters in sed?

When your pattern contains slashes, use alternative delimiters: sed 's|/usr/local|/opt|g' or sed 's#/home#/users#g'. Any character can follow the 's' [^29^].

How do I delete empty lines with sed?

Use sed '/^$/d' file.txt where ^$ matches lines with nothing between start and end [^27^].

What is the difference between -i and -i.bak?

-i edits in place with no backup. -i.bak creates a backup with .bak extension before editing [^27^].

How do I match case insensitive?

Use the I flag: sed 's/foo/bar/I' or sed 's/foo/bar/i' depending on your sed version [^28^].

Can sed work with multiple lines?

Yes, using the hold buffer (h, H, g, G commands) and pattern space operations. However, awk is often better for multi-line processing [^28^].


Technical Specifications

  • Zero dependencies: Runs entirely in browser
  • No backend required: Static hosting compatible
  • Offline capable: Works without internet after initial load
  • Privacy focused: No data leaves your browser
  • Keyboard shortcuts: Full keyboard navigation support

Related Tools

  • AWK Command Builder
  • grep Pattern Generator
  • Regex Tester
  • Diff Checker
  • JSON Path Finder

Resources


Last Updated: 2025 License: Free to use Platform: Web-based, works on all modern browsers