我想创建一个指向相对符号链接的相对符号链接,而不是相对符号链接的目标。似乎在创建相对符号链接时会ln
解析TARGET
而不是指向实际的TARGET
. 这个过程可以跳过吗?在下面的示例中,我想rsym-to-existing-rsym.txt
指向rsym-to-target.txt
,而不是target.txt
。
当我为尚不存在的符号链接创建符号链接时,它可以工作(下面示例中的rsym-to-future-rsym.txt
-> future-rsym-to-target.txt
->target.txt
链)。
例子
# Create initial structure
$ mkdir -p temp
$ touch temp/target.txt
# Now, create relative symlinks
$ ln -s -r temp/target.txt temp/rsym-to-target.txt
$ ln -s -r temp/rsym-to-target.txt temp/rsym-to-existing-rsym.txt
# Note that at this point temp/future-rsym-to-target.txt doesn't exist yet
$ ln -s -r temp/future-rsym-to-target.txt temp/rsym-to-future-rsym.txt
$ ln -s -r temp/target.txt temp/future-rsym-to-target.txt
$ tree -F temp/
# Note that rsym-to-existing-rsym.txt points to target.txt, not to rsym-to-target.txt
temp/
├── future-rsym-to-target.txt -> target.txt
├── rsym-to-existing-rsym.txt -> target.txt
├── rsym-to-future-rsym.txt -> future-rsym-to-target.txt
├── rsym-to-target.txt -> target.txt
└── target.txt
# Maybe the tools I'm using are just nice to me and resolve final paths?
# No, when I delete rsym-to-target.txt symlink rsym-to-existing-rsym.txt still points to target.txt
$ rm temp/rsym-to-target.txt
tree -F temp/
temp/
├── future-rsym-to-target.txt -> target.txt
├── rsym-to-existing-rsym.txt -> target.txt
├── rsym-to-future-rsym.txt -> future-rsym-to-target.txt
└── target.txt