Sed Command Examples

SED command in UNIX is stands for stream editor and it can perform lot’s of function on file like, searching, find and replace, insertion or deletion.

Syntax

Examplas

Here is just a brief list of examples of how to use sed

Here the “s” specifies the substitution operation. The “/” are delimiters.

Replacing all the occurrence of the pattern in a line

Parenthesize first character of each word

Replacing string on a specific line number

Printing only the replaced lines use the -n option along with the /p print flag to display only the replaced lines.

Replacing string on a range of lines

Deleting lines from a particular file

Examples:

Delete a particular line

Delete a last line

Delete from nth to last line

Delete pattern matching line

Learn more at

GNU Sed Manual

----------

Home

Linux

Notes

MicroLog

----------

© DarknessCode