CLI Tools Sed Sed: Stream Editor Basics

Sed: Stream Editor Basics

AS
Aman Saurav
| Jul 4, 2025 |
10 min read
#regex #editing

Sed performs basic text transformations on an input stream (a file or input from a pipeline).

Substitution

The most common use case is find and replace.

sed 's/old-text/new-text/' file.txt

The above only replaces the first occurrence per line. Add g at the end for global replacement: s/old/new/g.