How to create relative symbolic link in mac OS?

Maggie picture Maggie · May 1, 2013 · Viewed 35.8k times · Source

How to create a relative symbolic link that would always point to original folder two levels up? I would like to create a computer-independent alias that would work on any machine, provided that the original folder exists two levels up.

Basically, what I want is this:

  |-- Original    
  |-- folder 1    
    |-- folder 2
      |-- Original alias   

I need this for my XCode project structure. I've tried:

ln -s Original /../../Original

but it creates an alias that cannot find its original folder.

Answer

twalberg picture twalberg · May 1, 2013

I think, you have the order of the arguments backwards. It should be:

$ ln -s <dest> <link>

Where <dest> becomes the contents of the new link created.

In your specific example:

$ cd "folder 1"/"folder 2"
$ ln -s ../../Original Original

Or, in one command, from base directory:

$ ln -s Original "folder 1/folder 2/Original"