Text manipulation using sed

Replace string1 with string2

sed 's/string1/string2/g'

Modify anystring1 to anystring2

sed 's/\(.*\)1/\12/g'

Remove comments and blank lines

sed '/ *#/d; /^ *$/d'

Concatenate lines with trailing \

sed ':a; /\\$/N; s/\\\n//; ta'

Remove trailing spaces from lines

sed 's/[ \t]*$//'

Escape shell metacharacters active within double quotes

sed 's/\([\\`\\"$\\\\]\)/\\\1/g'

Print 1000th line

sed -n '1000p;1000q'

Print lines 10 to 20

sed -n '10,20p;20q'

Extract title from HTML web page

\(.*\)< \/title>.*/\1/ip;T;q'<br />sed -n 's/.*