SED

Introduction to SED

When to use SED Stream Editor

SED ¯SÂI

SED Characteristics

Operation Model

Execution Sequence

Drawback

Invoke

Options

Command Format

Line Number Addressing

Context Addressing

¨Ò

Function

Substitute Function

Substitute Function

Input-Output Functions

Multiple Input-Line Functions

Hold and Get Functions

Flow Control Functions

Miscellaneous Functions

Semicolon ';'

Index of sed commands

¨Ò

Squeezing blank lines (like cat -s)

Centering lines

Delete comments from C code

Increment a number

Search make targets

Rename to lower case

chars of lines

lines of files

Transform text into a C 'printf'able string

Prefix non blank lines with their numbers (cat -b)

Prefix lines by their number (cat -n)

Count chars of input (wc -c)

Count lines of input (wc -l)

Count words of input (wc -w)

Print the filename component of a path (basename)

Print directory component of a path (dirname)

Print the first few (=10) lines of input

Print last few (=10) lines of input

The tee(1) command in sed

Print uniq lines of input (uniq)

duplicated lines of input (uniq -d)

Print only and only duplicated lines (uniq -u)

References