consider the following :
x/ ph/ file1.txt -> ./../file1.txt file1.txt y/ ph/ -> /x/ph/ (this is full absolute path of x/ph) file1.txt
/y/ph is a symlink for
ph folder in
file1.txtis a relative symlinks.
it works correctly in
x folder however if you open
/y/ph/file1.txt instead of opening
/y/file1.txt it opens
the goal here is to have the same directory (lets say a program) in multiple places with different config files without having to have multiple copies of the program.
Symbolic links can hold arbitrary text; if later resolved, a relative link is interpreted in relation to its parent directory.
so relative links are relative to the actual folder's path not the current working directory. the question is : is there any workarounds for this ?
mkdir x y x/ph echo x1 > ./x/file1.txt echo y1 > ./y/file1.txt ln -s $(pwd)/x/ph ./y/ph cd ./x/ph ln -s ./../file1.txt cd ../.. cat ./x/ph/file1.txt cat ./y/ph/file1.txt
expected result is
x1 y1 but you get
to make the question clearer, run the test case in an empty folder. and try the following commands in the folder:
bor@borpc:~/tmp$ readlink -f ./x/ph/file.txt /home/bor/tmp/x/ph/file.txt bor@borpc:~/tmp$ readlink -f ./y/ph/file.txt /home/bor/tmp/x/ph/file.txt --------------^
i want that
x there to be
y. that is to make the relative symlink resolve based on
pwd (current working directory or path used to access it) rather than the actual path of the actual file.
if it is possible how would one achieve such behavior.