News for hackers. Stuff that matters.
Re:Moreutils – Unix tools that nobody thought to write (2012) by ISO-morphism on Saturday August 22, 2020 @08:33AM (#24243689)
Yes, but -i on sed is specific to GNU, I don't think it exists on BSD/OSX/busybox
Re:Moreutils – Unix tools that nobody thought to write (2012) by lhoursquentin on Saturday August 22, 2020 @09:28AM (#24243971)
-i is definitely not specificed by POSIX, but it supported on all those platforms with some small differences, for instance on OSX the backup extension (-i.bak) is not optional.
Re:Moreutils – Unix tools that nobody thought to write (2012) by gpanders on Saturday August 22, 2020 @11:17AM (#24244685)
Amazingly, there is no portable way to use -i that works on both GNU and BSD sed implementations. Which means if you’re writing a portable script, you can’t use -i at all.

(Would love to be proved wrong on this)

Re:Moreutils – Unix tools that nobody thought to write (2012) by bewuethr on Saturday August 22, 2020 @01:46PM (#24245774)
According to Stack Overflow [1], this works:

    sed -i.bak 's/foo/bar/' filename
[1]: https://stackoverflow.com/a/22084103/3266847
Re:Moreutils – Unix tools that nobody thought to write (2012) by gpanders on Saturday August 22, 2020 @02:03PM (#24245928)
That works when specifying a backup extension, but not if you don’t want to create a backup file.

    sed -i ‘’ ...
works on BSD sed but not GNU. Meanwhile:

    sed -i’’ ...
    sed -i ...
both work on GNU but not BSD.
Re:Moreutils – Unix tools that nobody thought to write (2012) by bewuethr on Sunday August 23, 2020 @03:38PM (#24254654)
Well, yes, you can't use it without creating a backup file, but it uses "-i" and is portable.