Use inreplace not sed.