You are currently browsing the monthly archive for March 2007.
It’s the simple things in life… Sometimes you simply want to know the canonical path for your current working directory.
Here is a symbolic link to a directory.
lrwxrwxrwx 1 14 Mar 29 10:54 /home/crashingdaily/symlink -> im/a/real/path
I change to the directory using the symbolic link.
The ‘pwd’ bash builtin does not resolve symbolic links so reports that I’m in the ‘symlink’ directory.
/home/crashingdaily/symlink
‘/bin/pwd’ reports the canonical path.
/home/crashingdaily/im/a/real/path
I can leverage this to quickly change my path from symlinked to real.
/home/crashingdaily/symlink
$ cd `/bin/pwd`
$ pwd
/home/crashingdaily/im/a/real/path
Also see
readlink is advantageous if you need to resolve paths outside your current working directory.
Update: Sometimes the simpler things are right under your nose.
and
were sitting there all along. No need for /bin/pwd (for bash at least). RTFM, indeed.