The Stream Editor (sed)

The sed command is a powerful stream editor used for text manipulation. It can be used to perform various text transformations, such as finding and replacing text in files or streams.

The sed command is a powerful stream editor used for text manipulation. It can be used to perform various text transformations, such as finding and replacing text in files or streams.


Basic Syntax

sed 's/find/replace/' [file]

By default, sed prints the modified content to the terminal without changing the original file. You can use the -i option to edit files in-place.


Examples

Find and replace text in a file

sed 's/old/new/' file.txt

Example: File file.txt contains:

The old car is rusty.

Command:

sed 's/old/new/' file.txt