Hacker News new | ask | show | jobs
by bewuethr 2130 days ago
According to Stack Overflow [1], this works:

    sed -i.bak 's/foo/bar/' filename
[1]: https://stackoverflow.com/a/22084103/3266847
1 comments

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.
Well, yes, you can't use it without creating a backup file, but it uses "-i" and is portable.