Ubuntu – sed and what is it used for

command linesed

I've been seeing a lot of sed lately, and I find it to be a rather confusing command.
The manpages weren't particularly helpful, but I do know that it can be used for parsing the output of other commands.

What exactly is sed and what are it's uses? I'm looking for a comprehensive answer covering what sed is, what commonly it is used for, and some basic examples/syntax.

Best Answer

In basic usage it is used for 'search and replace' with strings.

echo "The quick brown fox jumps over the lazy dog" | sed 's/dog/cat/'

returns

"The quick brown fox jumps over the lazy cat"

Sed really shines when regular expressions are used with it.

You might like to take a look at this article about sed, its quite comprehensive.

Related Question