Results 1 to 5 of 5
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 ...
- 10-25-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 4
virtual directories?
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:
dir1
file1dir2
file2
file3
file4
You then create a "virtual directory" called dir3. If you type ls dir3 at a console, you see:
file1
file2
file3
file4
Obviously one solution would be to make links to dir1 and dir2 within dir3; but an ls dir3 would then produce:
dir1
dir2
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.
Any ideas?
- 10-25-2007 #2
- 10-25-2007 #3Just Joined!
- Join Date
- Oct 2007
- Posts
- 4
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.
- 10-26-2007 #4Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
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.Code:for file in ../some/dir ; do ln -s $file ; done
- 10-27-2007 #5Just Joined!
- Join Date
- Oct 2007
- Posts
- 4
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.Code:for file in ../some/dir/* ; do ln -s "$file" ; done
Thanks again for the useful tips.


Reply With Quote
