I don't quite get why the thinking about this simple problem has to be so complex - but perhaps I just got the question the wrong way. Anyways: when I needed a similar functionality, I used:
That did the trick in my case.
ls man page:
when showing file information for a symbolic link,
show information for the file the link references
rather than for the link itself
For instance, I've made me a
/media/stick shortcut to access the data on my USB stick.
ls -l /media/stick will show the actual link, while
ls -lL /media/stick will show the contents on the USB stick.
After some deeper research about the difference between the inner workings of
-L, I finally came across an excellent article about this matter on Shallow Thoughts blog (even featuring some neat shell script tricks for your pleasure!)
This points out the subtle differences between the two options (way better than the original manual does!) as follows:
-H -- only dereference those links explicitly mentioned on the command line
-L -- dereference links even if they are not mentioned on the command line
(When these two are used with simple everyday tasks, there ought to be no difference in the output in general.)
Besides: Should you prefer to remember the long form (
--option), it's most probably less cumbersome to memorize
--dereference than the excessively long monster of