search
Get Started
search
sed - Command Line
zoom_in Click to enlarge

sed

description sed Overview

sed (Stream Editor) is the classic tool for non-interactive text transformation. It reads text line by line, applies specified edits (like search-and-replace), and prints the result to standard output. It is foundational knowledge for shell scripting, allowing users to sanitize input, reformat logs, or perform bulk text replacements reliably across massive datasets.

help sed FAQ

Why does sed -i work differently on macOS and GNU/Linux?

GNU sed accepts an in-place edit without requiring a backup suffix, while BSD sed on macOS expects a suffix argument, which may be an empty string. A portable script should account for this difference instead of assuming identical command syntax.

How do I replace text containing forward slashes with sed?

Sed substitution commands can use another delimiter, such as `sed 's|/old/path|/new/path|g'`. This avoids escaping every slash while retaining the usual `s` command and global `g` flag.

Why did my sed replacement change only the first match on each line?

By default, `s/old/new/` replaces only the first matching occurrence in each input line. Adding the `g` flag as `s/old/new/g` replaces every non-overlapping match on that line.

When should I use awk or Perl instead of sed?

Sed is well suited to line-oriented substitutions, deletions, and simple transformations. Awk is usually clearer for field-based calculations, while Perl is often easier for complex regular expressions or multiline processing.

Reviews & Comments

Write a Review

rate_review

Be the first to review

Share your thoughts with the community and help others make better decisions.

Save to your list

Save your favorites and follow how their scores change over time.

Save favorites
Get updates
Compare scores

Already have an account? Sign in

Compare Items

See how they stack up against each other

Comparing
VS
Select 1 more item to compare