Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create relative symbolic link in mac OS? [closed]

Tags:

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.

like image 605
Maggie Avatar asked May 01 '13 12:05

Maggie


People also ask

How do you create a symbolic link on a Mac?

Find the file or folder you want to create a symlink for, right-click on it, and select Services followed by Make Symbolic Link. It'll create the symlink in the same folder as the original file/folder. You can move it around though if you want.

How do you create a relative path in a symbolic link?

As the most common shells expands paths, to create a relative symlink you should quote the "source path". Also, the -s parameter means --symbolic . ln creates hard links by default.

Can symbolic links be relative?

Symbolic link can be of two types Relative or Absolute.

How do I find the relative path on a Mac?

Open Finder on your Mac. From the Mac menu bar, select “View” Choose “Show Path Bar” (This surfaces the path for any file selected at the bottom of the Finder window.


2 Answers

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" 
like image 129
twalberg Avatar answered Sep 18 '22 15:09

twalberg


take out the first / - thats an absolute link from root, you want ../../ to be relative from current location.

like image 30
dmp Avatar answered Sep 22 '22 15:09

dmp