sed Substitutions
Substitute (find and replace) "good" with "bad" on each line
sed 's/good/bad/' + replaces only 1st instance in a line
sed 's/good/bad/5' + replaces only 5th instance in a line sed 's/good/bad/g' + replaces all instances in a line sed 's/\(.*\)good\(.*good\)/\1bad\2/' + replace the next-to-last case sed 's/\(.*\)good/\1bad/' + replace only the last case Substitute "good" with "bad" only for lines which contain "bla" sed '/bla/s/good/bad/g'
Substitute "good" with "bad" except for lines which contain "bla"
sed '/bla/!s/good/bad/g'