Symbolic links can sometimes be confusing, particularly when one symbolic link includes another in its path:
lrwxrwxrwx 1 pcunixapl pcunixapl 18 Sep 6 10:23 foo-web -> vhosts/foo-web.com lrwxrwxrwx 1 pcunixapl pcunixapl 19 Sep 5 05:54 vhosts -> /home/httpd/vhosts/
You can quickly resolve symbolic links with readlink:
$ readlink vhosts /home/httpd/vhosts/ readlink foo-web vhosts/foo-web.com
But that foo-web isn't really 100% true, because "vhosts" is another symbolic link itself. If you want it to follow the trail, use "readlink -f":
$ readlink -f foo-web /home/httpd/vhosts/foo-web.com
There are a couple of other options to readlink that make it easy to use in shell scripts; it's always nice when the author of a utility pays attention to little details like that.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2011-03-17 Tony Lawrence