BSD and GNU sed have some small differences in what arguments they accept. I just learned that I have to use different command lines when using -i:

sed -i '' # BSD
sed -i    # GNU

I solved this with an IMO ugly hack involving storing the correct parameter in an environment variable.

Is there a nicer way to do that?

  • 1
    Yeah. Don't use -i. It's just an ugly hack anyway. – mikeserv Aug 5 '15 at 20:01
  • 1
    You think so? I use it all the time.. – daniel kullmann Aug 5 '15 at 20:04
  • 1
    Yes. Of course it's called in-place editing but that's not at all what it is. Rather it's replace. It's riddled with problems where user/group permissions are concerned, fs quotas, timestamps, and what-have-you. Anyway, there is an answer to your question. – mikeserv Aug 5 '15 at 20:07

Browse other questions tagged or ask your own question.