Shell sed: rename(): Not a directory

Hi!

Why does sed exaust "sed: rename(): Not a directory" called
sed -i ~ 's/^\#\+\(PermitRootLogin\) .*$/\1 yes/g' /etc/ssh/sshd_config

The manual states:
Code:
     -i extension
             Edit files in-place similarly to -I, but treat each file
             independently from other files.  In particular, line numbers in
             each file start at 1, the "$" address matches the last line of
             the current file, and address ranges are limited to the current
             file.  (See Sed Addresses.) The net result is as though each file
             were edited by a separate sed instance.

It looks like /etc/ssh/sshd_config being used as if it where a directory, creating backups within: /etc/ssh/sshd_config/sshd_config~

This is with FreeBSD-11-STABLE, FreeBSD-12-STABLE.
It works as expected with FreeBSD-10-STABLE, FreeBSD-13-STABLE, FreeBSD-14-CURRENT.

Bug?
 
~ is a special shell character, the shell replaces it with the path to your home directory. If you want to pass a literal ~ to a command, you have to escape it, e.g. sed -i \~ [...]
 
Back
Top