Show a text file and replace text, here: replace foo with bar
sed s/foo/bar/g file.txt

Use ” if your search patterns contains spaces
sed 's/foo foo/bar bar/g' file.txt

Change a text file in place and replace text, here: replace foo with bar
sed s/foo/bar/g file.txt -i

Redirect output to Disk
sed s/foo/bar/g file.txt > newfile.txt

delete 5th line
sed 5d file.text

Delete lines matching ‘foo’
sed /foo/d file.txt

Print line 8
sed -n '8p' file.txt

Print lines 8-10
sed -n '8,10p' file.txt

Append new line containing ‘bar’, after lines containing ‘foo’
sed '/foo/a bar' file.txt

Insert “hello” to the end of line 9
sed 'i9 hello' file.txt

Examples:
sed 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config

http://sed.sourceforge.net/sed1line.txt