4

On Linux (redhat/ubuntu/you name it), I can do this:

$readlink -f myfile.txt
/tmp/local/path/to/myfile.txt

On OSX (yosemite):

$ readlink -f eclipse-projects.xml 
readlink: illegal option -- f

Can someone tell me what's going on? What's the "equivalent" of -f on osx? (And why do people love to make things sooooo inconsistent?!)

5
  • 1
    serverfault.com/q/40144
    – choroba
    Nov 19, 2015 at 16:12
  • OS X is not Linux. It is Unix. ;) You can install GNU coreutils via brew if you want them.
    – Daniel B
    Nov 19, 2015 at 16:15
  • 1
    @DanielB Yeah, I hear ya... but still, some consistency doesn't hurt Nov 19, 2015 at 16:18
  • This was answered at length in a different forum: How can I get the behavior of GNU's readlink -f on a Mac? Nov 19, 2015 at 23:42
  • 2
    @Daniel B Yup, and even more specifically it's very similar to (and based on) BSD. To the OP, Apple specifically loves to make things inconsistent. They actively eschew industry standards. A good example is their SSDs, which are exactly the same as any other SSD but have proprietary pin arrangements and cost 4x as much. I'm pretty sure the 2011 to 2013 style SSDs are literally M.2 connectors with the cutout slot moved to a different location.
    – Layne B
    Oct 29, 2018 at 21:56

1 Answer 1

0
# Return the canonicalized path (works on OS-X like 'readlink -f' on Linux); . is $PWD
function realpath {
    [ "." = "${1}" ] && n=${PWD} || n=${1}; while nn=$( readlink -n "$n" ); do n=$nn; done; echo "$n"
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .