Table of Contents
Overview
sed (stream editor) is a powerful text processing tool that performs text transformations on an input stream (file or input from a pipeline).
Key Features
- Line-based text processing
- Regular expression support
- In-place file editing
- Multiple commands
- Pattern matching
- Hold buffer operations
- Address ranges
- Branching capabilities
Basic Usage
Simple Substitution
Common Options
Command Syntax
Address Specification
Multiple Commands
Pattern Space Operations
Basic Operations
Hold Buffer Operations
Regular Expressions
Basic Patterns
Extended Patterns
Advanced Features
Branching
Flow Control
Multi-line Operations
Common Use Cases
Text Transformation
Best Practices
Error Handling
Example Scripts
Log Processing
Configuration File Update
HTML Processing
Remember:
- Test commands on sample data first
- Make backups before in-place editing
- Use appropriate regex delimiters
- Consider performance for large files
- Document complex transformations
- Handle special characters properly
For detailed information, consult the sed manual (man sed
).