LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ln with -t option, to create relative symlink not working (https://www.linuxquestions.org/questions/linux-newbie-8/ln-with-t-option-to-create-relative-symlink-not-working-4175534170/)

abefroman 02-16-2015 06:19 AM

ln with -t option, to create relative symlink not working
 
I'm trying to recreate a relative symlink, to link "asymlink" to "somedir/actualfile" in /root/test/ but its creating 2 symlinks instead.

Code:

[root]# ln -t /root/test/ -s somedir/actualfile asymlink
[root]# ll /root/test/
total 4
lrwxrwxrwx 1 root root  18 Feb 16 06:15 actualfile -> somedir/actualfile
lrwxrwxrwx 1 root root    8 Feb 16 06:15 asymlink -> asymlink
drwxr-xr-x 2 root root 4096 Feb 16 06:15 somedir

I can do it with
Code:

cd /root/test
ln -s somedir/actualfile asymlink

but I'm trying to avoid the cd, and also avoid using the full path.

Does anyone know why the -t flag isn't working as expected?

pan64 02-16-2015 06:31 AM

ln <source file> -s <target file>
use both source and target with full path
Is that what you are looking for?

millgates 02-16-2015 06:37 AM

From man ln:

Code:

SYNOPSIS
      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)

You are using the 4th form. Both "somedir/actualfile" and "asymlink" are treated as targets. You can't both use -t and specify link name.
You can do the following, though, to avoid the cd:

Code:

ln -s somedir/actualfile /root/test/asymlink

abefroman 02-16-2015 06:57 AM

Code:

ln -s somedir/actualfile /root/test/asymlink
That worked, thanks!


All times are GMT -5. The time now is 04:17 PM.