What's the difference between ln -s and alias?

后端 未结 7 2032
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 09:42

I just found a workaround for a problem I was having with the subl command for Sublime Text 3 when the MacPorts version of python is installed. The instructions

7条回答
  •  情话喂你
    2020-12-23 10:09

    EDIT: Another comment leads me to realize the alias I'm talking about is a mac-specific 'finder' alias, whereas the aliases in question here are bash 'shell' aliases. My mistake.

    A symbolic, or soft, link points to a path: a location on the filesystem. If the file or folder located at the path is moved or renamed, the soft link will now point at nothing useful.

    An alias can contain a reference to a path, or to a file ID, or both, depending on the implementation. On Mac OS X at least, the default is both, but the path is favoured over the file ID. That is, as long as something exists at the path referenced by your alias, your alias will point to the path, just like a symbolic link does. But, if nothing exists at the path referenced by your alias, it will instead point to the original file ID.

    For example:

    Suppose you create a file, and then create an alias for it, by specifying the file path. The alias now contains the file's file ID, as well as the file's path. The alias will by default follow the file's path to take you to the file.

    If you now move the file to a different location, the alias will follow it by referencing the file's file ID. But, if you assign a NEW file to the same file path as the old one, the alias will now point to the new file, since it favours path over file ID.

    Reference: http://forums.macworld.com/index.php?/topic/142842-aliases-vs-symbolic-links/

提交回复
热议问题