Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Tip: creating symlinks to another folder
Posted 09-01-2013 at 07:46 PM by the dsc
Tags symlink
The syntax of "ln" requires full path information of the "source" file. Therefore, if you issue something like "for file in *.foo ; do ln -s ./$file /other-folder/somewhere/$(echo $file | sed s/foo/bar/) ; done", the produced symlinks will be empty.
To avoid that, the command must be:
for file in *.foo ; do ln -s $PWD/$file /other-folder/somewhere/$(echo $file | sed 's/foo/bar/') ; done
$PWD, the environment variable of the current folder, doesn't come automatically, so if it's not stated, you'd be creating just "empty" symlinks with the correct names.
The same holds true for something simpler like "ln -s file-here ./subfolder/symlink". It should be "ls -s $PWD/file-here ./subfolder/symlink" instead.
To avoid that, the command must be:
for file in *.foo ; do ln -s $PWD/$file /other-folder/somewhere/$(echo $file | sed 's/foo/bar/') ; done
$PWD, the environment variable of the current folder, doesn't come automatically, so if it's not stated, you'd be creating just "empty" symlinks with the correct names.
The same holds true for something simpler like "ln -s file-here ./subfolder/symlink". It should be "ls -s $PWD/file-here ./subfolder/symlink" instead.
Total Comments 0