News for hackers. Stuff that matters.
Re:GNU ed 1.15 by bonzini on Friday January 04, 2019 @09:57AM (#18824409)
GNU sed has supported sed -i for about 15 years; BSD sed supports it too but you have to write sed -i ''.

The difference is that ed reads the entire input in memory, but it doesn't break symlinks. sed's in-place editing mode (just like perl -i or the newer awk -i inplace that is supported by GNU awk) breaks symlinks, on the other hand it can operate on arbitrarily large files.

Re:GNU ed 1.15 by ibotty on Friday January 04, 2019 @10:25AM (#18824605)
> [BSD sed]

you can also do

    sed -i -e 's/a/b/' file
which will work for GNU and BSD sed.
Re:GNU ed 1.15 by bonzini on Friday January 04, 2019 @03:46PM (#18827438)
No, it doesn't. On BSD sed it will produce a backup file named file-e. The portable way is to use-i.bak and then get rid of the backup file.
Re:GNU ed 1.15 by LukeShu on Friday January 04, 2019 @10:46AM (#18824797)
GNU sed has `--follow-symlinks` to have `sed -i` avoid turning symlinks in to regular files.
Re:GNU ed 1.15 by bonzini on Friday January 04, 2019 @11:51AM (#18825464)
It would still break hard links though.
Re:GNU ed 1.15 by a1369209993 on Friday January 04, 2019 @02:26PM (#18826911)
If you have hard links your file system is broken.
Re:GNU ed 1.15 by maccio92 on Friday January 04, 2019 @10:19AM (#18824563)
so... you can't use sed for the same task because it breaks symlinks?
Re:GNU ed 1.15 by LukeShu on Friday January 04, 2019 @10:48AM (#18824816)
By "breaks symlinks", he means that if you run `sed -i` (without `--follow-symlinks`) on a symlink, then it will turn the symlink in to a regular file. GNU sed has `--follow-symlinks` which adjusts this behavior to edit the target of the symlink, and leave the symlink itself alone.