sed

Stream editor for transforming text.

KaliParrotLinuxpassive

pkg: sed

sed edits streams non-interactively — substitute, delete and insert across files and pipelines.

Syntax

sed 's/old/new/g' [file]

Example

sed -n 's/.*token=\([a-f0-9]*\).*/\1/p' file

Extracts a hex token value from each matching line.

Options & flags

What each switch does. Toggle them in the builder below to assemble a command.

's/old/new/g' <value>Substitute all occurrences on each line.
-nSuppress automatic printing (use with p).
-i <value>Edit the file in place.
-E <value>Extended regex.
'Nd' <value>Delete line number N.

Command builder

Tick options (and fill any values) to build a ready-to-copy command.

sed

Usage examples

sed 's/foo/bar/g' file

Replace every foo with bar.

sed -n '10,20p' file

Print only lines 10-20.

Advantages
  • Fast in-place edits
  • Regex power in pipes
Disadvantages
  • Regex syntax pitfalls
  • Hard to read
Tags
#text#scripting

Official docs: GNU sed

Related commands

Frequently asked questions

What is sed used for?
sed edits streams non-interactively — substitute, delete and insert across files and pipelines.
What is an example sed command?
A common example is: sed -n 's/.*token=\([a-f0-9]*\).*/\1/p' file — Extracts a hex token value from each matching line.
Is sed part of Kali Linux?
Yes. sed ships with Kali Linux (and Parrot OS). If missing, install it with: sudo apt install sed.
What category of security tool is sed?
sed is a Core Linux tool with a passive-risk profile when run against a live target.

Try recon tools live

Run real scans against a domain you control, stage by stage.

Open the lab →