Editing Streams with sed
If you need to modify text in a pipeline or in a file, sed is your best friend. Its name is short for “stream editor” and it’s very handy. While you can do many things with sed, the most common use is to replace some text with other text, similar to how you’d use the find and replace feature in your text editor.
Like other tools, sed can read its input from a file or from standard input. Try it out. Print out “Hello World” and use sed to replace “Hello” with “Goodbye”:
|||$ echo "Hello World" | sed -e 's/Hello/Goodbye/'|
In this example, you’re sending “Hello World” via a pipe and then using the -e flag to specify an expression. The expression s/Hello/Goodbye/ is a basic substitution. ...