I want to create a symlink
~/.pm2/logs -> /opt/myapp/log
When I run
ln -sFf /opt/myapp/log ~/.pm2/logs
I get a symlink
~/.pm2/logs/log -> /opt/myapp/log
which is not what I want.
I'd prefer a POSIX-compatible solution if possible.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
As other answers say, there is already a directory there.
To avoid this and instead get an error-message, use the
-T option, unfortunately I don't think this is Posix (it is GNU).
From the Gnu
ln manual (same for cp and mv).
ln [OPTION]... [-T] TARGET LINK_NAME (1st form) ln [OPTION]... TARGET (2nd form) ln [OPTION]... TARGET... DIRECTORY (3rd form) ln [OPTION]... -t DIRECTORY TARGET... (4th form)
Note form 1 without the
-T is ambiguous with form 3 (both have two arguments).
In Posix you can force this non-ambiguity by putting a
/ at the end of a directory name, in form 3, but I don't think there is any thing you can do the other way around. This is why Gnu added the