How to find the final target of a daisy-chain of symbolic links?

I needed to issue several commands to follow a chain of symbolic links to the final target.

Is there a command which will do it in a single step?

which updatedb
/usr/bin/updatedb  

ls -l /usr/bin/updatedb  
lrwxrwxrwx 1 root root 26 2010-09-01 16:22 /usr/bin/updatedb -> /etc/alternatives/updatedb  

ls -l /etc/alternatives/updatedb  
lrwxrwxrwx 1 root root 25 2010-09-01 16:21 /etc/alternatives/updatedb -> /usr/bin/updatedb.mlocate  

ls -l /usr/bin/updatedb.mlocate  
-rwxr-xr-x 1 root root 34492 2010-03-24 21:16 /usr/bin/updatedb.mlocate  

Solution 1:

Use readlink -e <linkfile>. See readlink's manpage for more info on its arguments.