Getting started with sed
Remarks#
References
- FreeBSD sed man-page
- NetBSD sed man-page
- OpenBSD sed man-page
- Illumos sed man-page
- macOS (OS X) man-page
- Plan9 sed man-page
- GNU sed online manual
Versions#
Name | Initial Release | Version | Release Date |
---|---|---|---|
POSIX sed | 1992 | IEEE Std 1003.1, 2013 Edition | 2013-04-19 |
BSD sed | 1992 | FreeBSD 10.3 / NetBSD 7.0 / OpenBSD 5.9 | 2016-04-04 |
GNU sed | 1989 | 4.2.2 | 2012-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.