Reputation: 2115
I have a directory structure as follow and my current working directory is "a
".
-->cd a/
-->tree
.
└── b
└── c
└── d
└── e
└── foo
5 directories, 0 files
From directory a
, which means my current directory is a
. I want to create symlink of file b/c/d/e/foo
to b/c/d/e/bar
. So that when someone open b/c/d/e/bar
, contents of b/c/d/e/foo
will show up.
I tried following but it do not work, it means bar is pointing to b/c/d/f/foo
from current directory which is an invalid path.
-->ln -sf b/c/d/e/foo b/c/d/e/bar
-->tree
.
└── b
└── c
└── d
└── e
├── bar -> b/c/d/e/foo
└── foo
5 directories, 1 file
One dirty solution is to cd
to b/c/d/e
dir and perform ln -s
. but I am trying to avoid it.
Upvotes: 0
Views: 81
Reputation: 189936
The first argument to ln -s
is just a piece of text. If you put ln -s a/b/c d/e
then d/e
will point to d/a/b/c
because a/b/c
is now the target of the symlink e
in the directory d
.
So in your case, simply do
ln -s foo b/c/d/e/bar
Upvotes: 2