OmniBoot v1.5

Note: sed uses stdin and stdout. Newer versions support inplace editing with the -i option!

Concatenate lines with trailing \
sed ':a; /\\$/N; s/\\\n//; ta'

Convert to unix line endings
sed -i -e 's/\r//; s/\r\n$/\n/' file

Delete a particular line
sed -i 42d ~/.ssh/known_hosts

Escape shell metacharacters active within double quotes
sed 's/\([`"$\]\)/\\\1/g'

Extract title from HTML web page
sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q'

Get text between string1 and string2 in infile
sed -n '/string1/,/string2/p' infile

Insert a blank line above and below every line which matches "regex"
sed '/regex/{x;p;x;G;}'

Insert a blank line above every line which matches "regex"
sed '/regex/{x;p;x;}'

Insert a blank line below every line which matches "regex"
sed '/regex/G'

Make sure files end with empty newline
sed -i -e '$a\' file

Modify anystring1 to anystring2
sed 's/\(.*\)1/\12/g'

Number each line of a file (number on left, right-aligned)
sed = filename | sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'

Number each line of a file (simple left alignment).
sed = filename | sed 'N;s/\n/\t/'

Number each line of file, but only print numbers if line is not blank
sed '/./=' filename | sed '/./N; s/\n/ /'

Print 1000th line
sed -n '1000{p;q}'

Print lines 10 to 20
sed -n '10,20p;20q'

Print only lines which do NOT match regexp
sed '/regexp/d'

Print only lines which match regular expression
sed '/regexp/!d'

Print section of file from regular expression to end of file
sed -n '/regexp/,$p'

Print the line immediately after a regexp, but not the line containing the regexp
sed -n '/regexp/{n;p;}'

Print the line immediately before a regexp, but not the line containing the regexp
sed -n '/regexp/{g;1!p;};h'

Remove comments and blank lines
sed '/ *#/d; /^ *$/d'

Remove most HTML tags (accommodates multiple-line tags)
sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

Remove trailing spaces and tabs from lines
sed 's/^[ \t]*//'

Replace an IP-address
sed 's@[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}@192.168.0.1@'

Replace string1 with string2
sed 's/string1/string2/g'< file1 > file2

Replace text between startstring and endstring in file with content of insertfile.
sed -i -ne "/startstring/ {p; r insertfile" -e ":a; n; /endstring/ {p; b}; ba}; p" file

Right align numbers
seq 10 | sed "s/^/      /; s/ *\(.\{7,\}\)/\1/"