sed filter to substitute '!' for periods and '!!' for periods at the end of lines
sed -e 's_\.$_!!_g' -e 's_\._!_g' input_exp
I've used _
instead of /
for a slightly higher degree of readibility. You can also use
sed -e 's/\.$/!!/g' -e 's/\./!/g' input_exp
if you want to, of course. \n
stands for newline, and is not the same as end of line.