> [BSD sed]
you can also do
sed -i -e 's/a/b/' file
which will work for GNU and BSD sed.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.
GNU sed has `--follow-symlinks` to have `sed -i` avoid turning symlinks in to regular files.
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.
so... you can't use sed for the same task because it breaks symlinks?
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.
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.