Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #7940

Re: may i have a soft link poiting to two directories at the same time?

Date 2013-04-20 19:44 +0200
From David Brown <david.brown@removethis.hesbynett.no>
Newsgroups comp.os.linux.misc
Subject Re: may i have a soft link poiting to two directories at the same time?
References <5d6a6b03-844d-4fca-9e92-afdea3231b4b@googlegroups.com> <e6734axjqb.ln2@goaway.wombat.san-francisco.ca.us> <kkn4bn$cjo$1@dont-email.me> <hqi34axcud.ln2@goaway.wombat.san-francisco.ca.us>
Message-ID <Y--dnWxlp8NxTu_MnZ2dnUVZ8k6dnZ2d@lyse.net> (permalink)

Show all headers | View raw


On 18/04/13 00:03, Keith Keller wrote:
> On 2013-04-17, Rui Maciel <rui.maciel@gmail.com> wrote:
>> Keith Keller wrote:
>>
>>> Your initial proposal, pointing one symlink to two different places, is
>>> unfortunately not possible.  However, you can still use symlinks to
>>> avoid the copying step.  See if this works for your purposes:
>>>
>>> mkdir targetDir
>>> cd targetDir
>>> ln -s /path/to/dir1/* .
>>> ln -s /path/to/dir2/* .
>>
>> I would add that if all files are stored in the same file system then
>> instead of creating symlinks for the files, hard links should be used
>> instead.  In fact, this is exactly what they were created to accomplish.
>
> It depends on what the OP wants from the links after he's done with
> them.  If targetDir is simply an organizational tool, and he doesn't want
> those files to consume disk space if he ever deletes the contents of
> dir1 and dir2, then symlinks are better.  If he wants the files in
> targetDir to be able to survive deletions of dir1 and dir2, then hard
> links are better.
>
> In general, I use symlinks (and tell others to use symlinks) unless I
> know I have a specific purpose for which I need hard links.  One side
> effect is that I don't have to worry about explaining to people why
> making a hard link for a directory doesn't work, or why making a hard
> link across filesystems doesn't work--if they always use symlinks, these
> questions never arise.
>

In a situation like this, hardlinks are more likely to be the better 
solution.  They are more efficient, both in terms of disk space (a 
symlink is a small file - a hardlink is just a name in a directory) and 
usage (a symlink means an extra layer of indirection, while a hardlink 
is the file itself).  And because a hardlink /is/ the file, it is safe 
from deletion of dir1 and dir2 - with a softlink, the deletions can be 
done and leave a dangling softlink which is worse than useless.

Of course, it's important that the OP knows that with either kind of 
link, any changes made through the link affect the original file.

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

may i have a soft link poiting to two directories at the same time? www <xsli2@yahoo.com> - 2013-04-17 11:23 -0700
  Re: may i have a soft link poiting to two directories at the same time? Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> - 2013-04-17 11:45 -0700
    Re: may i have a soft link poiting to two directories at the same time? Rui Maciel <rui.maciel@gmail.com> - 2013-04-17 22:34 +0100
      Re: may i have a soft link poiting to two directories at the same time? Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> - 2013-04-17 15:03 -0700
        Re: may i have a soft link poiting to two directories at the same time? David Brown <david.brown@removethis.hesbynett.no> - 2013-04-20 19:44 +0200
  Re: may i have a soft link poiting to two directories at the same time? Aragorn <stryder@telenet.be.invalid> - 2013-04-17 20:51 +0200
  Re: may i have a soft link poiting to two directories at the same time? J G Miller <miller@yoyo.ORG> - 2013-04-17 20:27 +0000
  Re: may i have a soft link poiting to two directories at the same time? Bill Marcum <bill@nowhere.invalid> - 2013-04-24 06:42 -0400

csiph-web