sed

Getting started with sed

Remarks#

References

Versions#

NameInitial ReleaseVersionRelease Date
POSIX sed1992IEEE Std 1003.1, 2013 Edition2013-04-19
BSD sed1992FreeBSD 10.3 / NetBSD 7.0 / OpenBSD 5.92016-04-04
GNU sed19894.2.22012-12-22

Hello World

One of the most common use of Sed is text substitution that can be achieved with the s command.

In a terminal, type echo "Hello sed" | sed 's/sed/World/' and press Enter:

$ echo "Hello sed" | sed 's/sed/World/'
Hello World

“Hello World” should be output to the terminal.

The string “Hello, sed” is sent via pipe as input to the sed command that replace the word sed with World.

The syntax of a basic substitution command is s followed by the string or pattern to be searched and the substitution text. s command and strings are separated with a default / delimiter.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow