Sed
Sed (stream editor) is a classic Unix command-line utility for parsing and transforming text non-interactively, applying editing commands like substitution, deletion, and insertion to each line of input as it streams through.
Definition
Sed (stream editor) is a classic Unix command-line utility for parsing and transforming text non-interactively, applying editing commands like substitution, deletion, and insertion to each line of input as it streams through.
Overview
Sed processes text one line at a time from standard input or a file, applying a script of editing commands and writing the result to standard output, which makes it ideal for automated, repeatable text transformations rather than interactive editing. Its most iconic use is the substitution command, as in `sed 's/foo/bar/g'`, which replaces every occurrence of "foo" with "bar" across the input — a pattern so common it's become shorthand recognized across the Unix world. Alongside AWK and grep, Sed is a foundational piece of the classic Unix text-processing philosophy: small, single-purpose tools that do one thing well and combine through pipes in shell scripts to accomplish larger tasks. Where AWK is closer to a general programming language for structured data, Sed is deliberately narrower, focused specifically on line-based, regex-driven text editing and stream transformation. Sed remains heavily used today in shell scripts, build pipelines, and one-off command-line text manipulation, particularly for tasks like renaming patterns across files, filtering lines, and preprocessing text before feeding it to other tools. Its regular-expression-based commands are considered a foundational skill for anyone doing serious Unix/Linux command-line work. It is often mentioned alongside Linux in this space.
Key Features
- Non-interactive, line-by-line stream text editing
- Regular-expression-based find-and-replace (substitution)
- Commands for deletion, insertion, and line filtering
- Lightweight and available on virtually every Unix-like system
- Composable with other Unix tools via pipes
- Deterministic scripted editing, ideal for automation