I was wondering if it was possible to create a sort of "virtual directory" that lists contents of other directories in a single directory. If that sounded confusing, here's an example:
You then create a "virtual directory" called dir3. If you type ls dir3 at a console, you see:
Obviously one solution would be to make links to dir1 and dir2 within dir3; but an ls dir3 would then produce:
This allows me to get to them more quickly perhaps. Also, from here I could do an ls * or even an ls -R *.
While this is a viable solution, I just wondered if there was something out there that could accomplish this better. If not, I'm sure a perl or python script could get this done, although perhaps not worth the time.
I think you want Symbolic Links.
ln -s /home/dir1 /home/dir3
Check that out. Else I miss understoud you.
Symbolic links are good for linking one directory to another. But, what I was asking was if it was possible to link two or more directories to one directory.
I want the contents of two directories to be the output when I list the contents of one directory.
I thought the example made this clear, but perhaps it didn't. Seeing as you're the only one who replied, I'll assume it's not possible to do this in any traditional way.
Thanks for the response, though. :)
You may be able to use lndir for this, it will create a directory tree of symlinks to another directory tree, it might work for 2 directoried. Or you could use a simple bash loop:
Something similar to that ran for 2 different directories should work.
for file in ../some/dir ; do ln -s $file ; done
Thanks valan! :)
That's exactly what I wanted to do. lndir seems to accomplish this for the most part. I also tried the bash script, which has similar results. I had to tweak it a bit:
lndir should really be listed under See Also in the man page for ln.
for file in ../some/dir/* ; do ln -s "$file" ; done
Thanks again for the useful tips.