I know is an extremely old thread, but hey, some of these tips are still valid after years!!!
I just wanted to point out one advantage of using
readlink instead of the
awk solution is that readlink can follow links recursively as opposed to the awk solution.
for example, I found this thread trying to find a way to get the real java command in my system (in a script), so I ended up doing this:
Code:
readlink -f $(which java)
Which in fact has two symlinks:
Code:
which java -> /usr/bin/java
/usr/bin/java --symlink--> /etc/alternatives/java
/etc/alternatives/java --symlink--> /usr/lib/jvm/jdk1.8.0_11/bin/java