Pwd Command – How to Get Path Without Symlinks?

symlink

If I do pwd I notice it uses whatever symlinks I used to get into the current directory. Can I get it to tell me the "real" directory I'm in … i.e. the path from the root to my current directory without the use of any symlinks?

Best Answer

According to the POSIX manpage for pwd, the -P option may be of use:

-P The absolute pathname written shall not contain filenames that, in the context of the pathname, refer to files of type symbolic link.

Thus

$ pwd -P

should be what you need.

Related Question