0

I've symlinked a script file into my ~/bin, and when I do which foo the output is:

/Users/me/bin/foo

Is there a way to have this resolve the symlink and show me the real file?

3

use readlink

readlink -f "$(which command)"
  • Except the OP's /Users suggests he's on macOS and macOS' readlink doesn't support the -f option. – Stéphane Chazelas Aug 23 '17 at 9:28
1

With zsh:

print -r =foo(:A)

Or if foo is in the $cmd variable:

print -r $cmd:c:A

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.