$sed
Stream editor for filtering and transforming text using pattern substitutions.
sed [OPTIONS] SCRIPT [INPUT-FILE...]Try `sed` Live in Interactive Sandbox
Zero-install client simulation with real-time feedback.
Overview & How sed Works
`sed` (Stream Editor) performs basic text transformations on an input stream or file. Its most famous capability is search-and-replace using the `s/find/replace/g` syntax, allowing automated batch editing of source code and configurations without opening a visual editor.
Common Flags & Command Options
| Flag / Option | Description |
|---|---|
| -i | Edit files in place directly instead of printing to stdout. |
| -e [script] | Add the script to the commands to be executed. |
| -n | Suppress automatic printing of pattern space. |
Practical Real-World Examples
echo "localhost:3000" | sed "s/3000/8080/g"Replaces port 3000 with 8080 in the stream.
Frequently Asked Questions
What does the /g at the end of a sed substitution mean?
`/g` stands for global. It replaces all occurrences of the matching pattern on each line, rather than just the first occurrence.
Related Linux Commands
Search for matching string patterns or regular expressions inside text files.
Output the first part (top lines) of text files.
Output the last part (bottom lines) of files or stream real-time logs.
Print newline, word, and byte counts for files.
Print text strings or write data to files using shell redirection.
Pattern scanning and column text processing language.