Use readlink to, um, read the symlinks (instead of a whole lot of stat and gawk dodginess).
Much more robust.