1

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?

muru
  • 69,900
  • 13
  • 192
  • 292
daniel kullmann
  • 9,427
  • 11
  • 38
  • 45
  • 1
    Yeah. [Don't use -i](http://lists.gnu.org/archive/html/bug-gnu-utils/2013-09/msg00000.html). It's just an ugly hack anyway. – mikeserv Aug 05 '15 at 20:01
  • 1
    You think so? I use it all the time.. – daniel kullmann Aug 05 '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 05 '15 at 20:07

0 Answers0