FreeBSD and OSX have a version of stat
derived from NetBSD.
You can adjust the output with format switches (see the manual pages at the links above).
% cd /service
% ls -tal
drwxr-xr-x 22 root wheel 27 Aug 25 10:41 ..
drwx------ 3 root wheel 8 Jun 30 13:59 .s6-svscan
drwxr-xr-x 3 root wheel 5 Jun 30 13:34 .
lrwxr-xr-x 1 root wheel 30 Dec 13 2013 clockspeed-adjust -> /var/service/clockspeed-adjust
lrwxr-xr-x 1 root wheel 29 Dec 13 2013 clockspeed-speed -> /var/service/clockspeed-speed
% stat -f%R clockspeed-adjust
/var/service/clockspeed-adjust
% stat -f%Y clockspeed-adjust
/var/service/clockspeed-adjust
Some OS X versions of stat
may lack the -f%R
option for formats. In this case -stat -f%Y
may suffice. The -f%Y
option will show the target of a symlink, whereas -f%R
shows the absolute pathname corresponding to the file.
EDIT:
If you're able to use Perl (Darwin/OS X comes installed with recent verions of perl
) then:
perl -MCwd=abs_path -le 'print abs_path readlink(shift);' linkedfile.txt
will work.