3

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

4

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
  • 1
    good answer, but I want to add, that I must put absolute path as original location :) Please, add this information to answer – gaussblurinc Dec 27 '13 at 10:56
  • 2
    @gaussblurinc It should work also with relative paths and with ~ (it will be expanded by the shell). Which problem did you have? – Matteo Dec 27 '13 at 11:00
  • @Matteo I go to my directory and make ln -s Scripts/ ~/Scripts. This thing won't work for me, it seems, that symlink doesn't point on original :( – gaussblurinc Dec 27 '13 at 11:07
  • @gaussblurinc: ln -s THE_File_or_DIR_POINTED_AT The_NEW_SYMLINK. So ln -s /path/to/Scripts ~/Scripts will create in your homedir a "Scripts" symlink pointing at /path/to/Scripts . Do not use "~" elsewhere (ie, in the first parameter, for example) as it's only useable in some conditions, but not always. "~" is only evaluated to your homedir in special (common) cases, but not always. – Olivier Dulac Dec 27 '13 at 14:31
  • @gaussblurinc : not also that ls -al /the/symlink will list the symlink itself. ls -al /the/symlink/ [note the trailing /] will list the content of the directory pointed at. Ie, beware of some special side-effects of using a symlink. – Olivier Dulac Dec 27 '13 at 14:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .