Bill Jonas on Sat, 10 Nov 2001 03:30:46 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] combining directories


On Fri, Nov 09, 2001 at 06:46:20PM -0500, M. Jackson Wilkinson wrote:
> Brief question... is there any way to have a directory filled with a bunch
> of other directories filled with files appear as a directory of symbolic
> links to the real files?  Files are added to this directory heirarchy fairly
> often, so it'd be ideal that it be completely dynamic.  The directory is
> used for two purposes, and the more important of the two requires that the
> files be organized, while the other purpose can only look at one single
> directory nonrecursively.

Why not make the directory itself a symbolic link?  That's the most
elegant solution, IMHO.

If you really want the files themselves to be symbolically linked, you
might try a scripted approach.  Maybe something like:

------
#!/bin/bash

cd /path/to/directory/with/real/files
for file in $(find . -type f)
do
  if [ ! -h /path/to/directory/with/symlinks/$file ]
  then
    (cd /path/to/directory/with/symlinks
    && ln -s /path/to/directory/with/real/files/$file $file)
  fi
done

cd /path/to/directory/with/symlinks
for link in $(find . -type l)
do
  [ -f $link ] || rm $link
done
------

...and put in a crontab belonging to a user who has write privileges to
the directory with symlinks to run as occasionally as you can stand.
(For a few files, you wouldn't notice the difference if it were running
every minute, but I bet for large numbers of files...)

Oh, and a disclaimer: I haven't run the above.  I did, however, think it
through, and it *should* work. ;-)

-- 
Bill Jonas    *    bill@billjonas.com    *    http://www.billjonas.com/

Developer/SysAdmin for hire!   See http://www.billjonas.com/resume.html

Attachment: pgpxQ1rybsNaI.pgp
Description: PGP signature