I basically want to do this:
cat file | grep '<expression>' | sed 's/<expression>/<replacement>/g'
without having to write the expression twice:
cat file | sed 's/<expression>/<replacement>/g'
Is there a way to tell sed not to print lines that does not match the regular expression in the substitute command?
sed -n) to suppress the output and use p option (next to your g as in/g;pto print only those lines where changes takes place.