Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

In the terminal, I can use readlink on a symlink and it prints the target path of the symlink. E.g.

ln -s original.txt symlink.txt
readlink symlink.txt  # prints original.txt

How do I do this for Mac alias? I know the path is embedded in the resource fork, because the xattr command will display it in a raw format mixed with other data:

xattr -p -l com.apple.ResourceFork alias_file

However, I don't know enough about this format to extract it. I found the perl Mac::Files man page, but it has no examples, and Google was no help with it.

Maybe there's a way to use osascript to do it, similar to this answer?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

After more googling, I was able to pull together the pieces for an osascript command:

alias_path="your/alias/path"
osascript -e 'tell application "Finder"' -e "posix path of (original item of alias file (posix file \"$alias_path\") as text)" -e 'end tell'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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