sed is one of the advanced Unix commands for search/replace processing of text information. Command itself is very simple but most scenarios requiring its use are fairly advanced elements of systems administration. Thanks to Unix pipes, sed is often used chained with other commands to transform fragments of text.
Basic sed replace example
Here's how you can replace one of the words in an text given as input to sed:
[email protected]:~ $ echo 'hi, world'
[email protected]:~ $ echo 'hi, world' | sed 's/hi/hello/'
sed Replaces Every Matched Occurrence
It's not always obvious from a single line example, but sed processes all the lines of the given text input and makes as many replacements of matched patters as necessary:
[email protected]:~ $ echo -e 'hi, world \n hi again' | sed 's/hi/hello/'
sed is often used together with awk command, together they are a very powerful combination for processing large amounts of text and converting text into the desired format.