Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
3  
From Sed man page: Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors. –  saji89 May 22 '13 at 7:03
    
This should be a good place to start a comprehensive answer: en.wikipedia.org/wiki/Sed –  saji89 May 22 '13 at 7:12
    
info sed has a lot more than man sed. Then, in /usr/share/doc/sed, there's sedfaq.txt.gz. –  user25656 Nov 3 '13 at 14:00

2 Answers 2

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

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

returns

"The quick brown fox jumps over the lazy cat"

Where it really shines is when you start using regular expressions with it.

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

share|improve this answer

sed is a powerfull command that enables you make things (remove lines, string substitution, string filtering, etc).

I could give you a list of uses with args but internet is filled of that. Searching sed usage by examples bring me a lot of results, the cute one: http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.