Answer: No.
The originally accepted answer actually doesn't do what is requested (as noted in the comments). (I found this answer when looking for the reason a file-e
was appearing "randomly" in my directories.)
There is apparently no way of getting sed -i
to work consistently on both MacOS and Linuces.
My recommendation, for what it is worth, is not to update-in-place with sed
(which has complex failure modes), but to generate new files and rename them afterwards. In other words: avoid -i
.