symbolic link to a directory and relative path
listed in answer
ANSWER:
I don’t think you can do this. Shells nowadays keep track of how they got where they are, they keep track of current working directory by name, rather than just relying on file system and OS to keep it. That means the built-in cd can go “back up” the symbolic link, rather than just following “..” chains directly.
But when you run ls ../foo, ls isn’t aware that the shell got to a directory by following symbolic links. ls will do a stat() on “../foo”. The “..” part comes from the current directory, which has only a single “..” entry for it’s parent. The whole symbolic link thing doesn’t change the way directories have a single “.” and a single “..” entry. Symbolic links let the kernel insert an extra layer of indirection into file paths. When you pass “../whatever” to open() or stat(), the kernel just uses the current working directory of the process doing the call to figure out which single directory is named by “..”.
by Bruce Ediger from http://unix.stackexchange.com/questions/36320

New Comments