How to follow symbolic link(s) to the actual filename?



Hello,

It need a bash (shell) command(s) that can follow symbolic links to the actual filename.

A sample:

$ touch afile
$ ln -s afile link1
$ ln -s link1 link2

$ ls -l link2 link1 afile
-rw-r--r--  1 moma moma 0 2006-01-31 10:58 afile
lrwxrwxrwx  1 moma moma 5 2006-01-31 10:58 link1 -> afile
lrwxrwxrwx  1 moma moma 5 2006-01-31 10:58 link2 -> link1

If my bash script got "link2", how to find the actual filename (afile)?
-------------------------------------

I can make a dirty, looping bash script, but before that, any piece of advice is wellcome'd.

cheers,
  moma
  http://www.futuredesktop.org/how2burn.html#Ubuntu
.



Relevant Pages