AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
  • 1.  join content of 2 directories in an other dir

    Posted Tue May 08, 2007 10:39 AM

    Originally posted by: SystemAdmin


    Hello people!

    I have one question, does anybody know if there is anyway in UNIX to "join" directories content in just one dir?

    For instance...

    there are the dirs /download1 and /download2 that have a lot of subdirs and what I would like to do is to have a unique dir called download3 that I can see the content of download1 and download2 together.

    I need a kind of a way to create a link from dirs download1 and download2 to download3, so any updates in the 2 first dirs would also see in download3.
    Got it?

    Why? Just to simplify an application that needs to look in 2 or 3 downloadX dirs for specific conent(files) that would just need to look into the download3 to see all the other dirs as well.
    I run AIX 5.x.

    Thanks in advance.

    Narciso


  • 2.  Symbolic links

    Posted Tue May 15, 2007 05:20 AM

    Originally posted by: nagger


    Symbolic links will do this for you

    cd /download3
    ln -s /download1/* .
    ln -s /download2/* .

    This assumes the filenames in download1 and 2 are unique, as you can't have a single filename (link) that refers to the two files.


  • 3.  Re: Symbolic links

    Posted Tue May 15, 2007 11:37 AM

    Originally posted by: SystemAdmin


    This will not work for the problem that Narciso is trying to solve:
    "I need a kind of a way to create a link from dirs download1 and download2 to download3, so any updates in the 2 first dirs would also see in download3."

    Creating a symbolic link to all of the files in another directory is a one-shot deal. It will make all the files in the source directory visible from within the target directory, but any new files added to the source directory after the ln command is run will not automatically become visible from within the target directory. In order to see any files added after the original ln command is run, you would have to re-run the original command.

    Unfortunately, I do not know how to create a "join" of two directories. But it could be a handy thing to be able to do.


  • 4.  Re: Symbolic links

    Posted Wed May 16, 2007 07:25 AM

    Originally posted by: SystemAdmin


    Does he mean by this that when a new file is created in either download1 or download 2 a symlink to it is automagically created in download3? An interesting requirement to be sure. The one thing I've heard of that I think could be made to do this is "inotify".
    See http://www-128.ibm.com/developerworks/linux/library/l-inotify.html for details.
    Inotify is a Linux thing and I don't know if anybody's made it work on AIX.

    FWIW

    Jim Lane