Command Line: create a link to folder and access files in this folder

I want to do this thing:

  • Create a link to a folder.
  • Put this link in home (~) directory
  • Access files in linked folder from home directory (~/LinkToFolder/file)

What is the best way to it?

Main Problem. I have a set of scripts, that lay in specific folder in git repository local clone. I want to access them from home directory in very simple way.

perl ~/LinkToFolder/myWorkScript.pl param1 param2


Solution 1:

You can do this with Symlinks:

ln -s /path/to/original/location /path/to/intended/shortcut

For example, if you want ~/Scripts to go to ~/Dropbox/Documents/Scripts you can do…

ln -s ~/Dropbox/Documents/Scripts ~/Scripts

Then open ~/Scripts/test.sh will open the file at ~/Dropbox/Documents/Scripts/test.sh.

To see the symlink you can run ls -laPGh ~/Scripts.

For example, I have my Mobile Documents folder symlinked as iCloud, so…

ls -lapGh ~/iCloud
lrwxr-xr-x@ 1 grgarside  staff    41B 12 Nov  2012 iCloud -> /Users/grgarside/Library/Mobile Documents