sed --in-place caveats

How the "in-place" option works

--in-place describes what appears to be performed!
Actually a temporary file is created named sedXXXXXX' where XXXXXX is a string of random characters. As processing progresses output is written to the temporary file. Upon completion the original file is unlinked(removed) and the temporary file is renamed to the original name.

Modifies read-only files.
Fails if file is writable but its directory is not!

The permissions of a file define what operations are permitted on the contents of that file.
The permissions of a directory define what operations are permitted on the list of files. Renaming or deleting a file operates on the directory.
The use of --in-place on a file without write permission will result in the All file dates being updated and may change contents of the file.
sed d --in-place will delete the contents of a read-only file !

Attempts to operate on a writeable file in a non-writable directory will produce the error message:
sed: couldn't open temporary file seduwDhDf: Permission denied and exit with a code of 4.

Effects on attributes

Read, Write and Execute are preserved.
The flags archived, opaque, nodump, sappend, uappend, simmutable, immutable and hidden, ACL and eXended attributes are lost.

The timestamps on the output file will be now().

Effect on links

A file with hard links is seperated and only the file named in the command is changed. For example:
        ls -log 0*
        -rw-r--r--  2 11 Jun  5 12:46 0
        -rw-r--r--  2 11 Jun  5 12:46 0x
        sed --in-place "s/./x/" 0
        ls -log 0*
        -rw-r--r--  1 11 Jun  5 12:47 0
        -rw-r--r--  1 12 Jun  5 12:46 0x
When a symbolic link is operated on it is removed and the temporary file is renamed using the name of the symbolic link. For example:
    ls -log 0*
    -rw-r--r--  1 12 Jun  5 12:57 0
    lrwxr-xr-x  1  1 Jun  5 12:57 0s@ -> 0
    sed --in-place "s/./xx/" 0s
    ls -log 0*
    -rw-r--r--  1 12 Jun  5 12:57 0
    -rw-r--r--  1 13 Jun  5 12:59 0s
    -rw-r--r--  1 12 Jun  5 12:57 0

File space

There must be sufficient space for both the original file and the temporary file.

Interrupt

If the operation is quit or killed or HUnguP or if running from a remote session which aborts or is terminated, the temporary file is (sadly) not deleted!

reference