Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link one dir to many...

Status
Not open for further replies.

jping45

Technical User
Aug 22, 2001
49
US
I have a question for the Gurus...
I have a need to link one directory to several others.
EX.
DIR1 --> dira, dirb, dirc, etc...

Is there a way to do this within AIX???
 
Code:
ln -s DIR1 dira
ln -s DIR1 dirb
ln -s DIR1 dirc
...

ls -l will show dira, dirb etc as symbolic links to DIR1 (which they are) but you can use them as directories and, once you cd into them you will be in DIR1

Ok?

On the internet no one knows you're a dog

Columb Healy
 
Or did you want it the other way round, with "ls DIR1" showing the contents of all of "dira", "dirb" &c?
 
Actually, sjm2 you are correct... I'd like to have the ls DIR1 show the contents of dira, b and c...

Regards
 
Then you might be better off using an alias perhaps?

I want to be good, is that not enough?
 
AFAIK that can't be done, unless the contents of all these dirs is static and you create a symlink to each file in all dirs.

Or if you modify the ls command (hide it by an alias to a function which first creates all missing symlinks and then does the ls)

Of course ls -l would then show info about the symlinks, not info about the files...

And then what about filenames that exist in more than one dir that you want to link to.

Code:
$ pwd
/tmp/tt/DIR1
$ find /tmp/tt/dir[abc] -type f -exec ln -fs {} \;
$ ls
five   four   one    three  two
$ ls -l
total 0
lrwxrwxrwx   1 user     staff            17 Jun 12 10:34 five -> /tmp/tt/dira/five
lrwxrwxrwx   1 user     staff            17 Jun 12 10:34 four -> /tmp/tt/dirc/four
lrwxrwxrwx   1 user     staff            16 Jun 12 10:34 one -> /tmp/tt/dira/one
lrwxrwxrwx   1 user     staff            18 Jun 12 10:34 three -> /tmp/tt/dirb/three
lrwxrwxrwx   1 user     staff            16 Jun 12 10:34 two -> /tmp/tt/dirc/two
$ cd ..
$ pwd
/tmp/tt
$ find dir[abc] -type f -ls
36883    4 -rw-r--r--  1 user      staff            4 Jun 12 10:31 dira/one
36887    4 -rw-r--r--  1 user      staff            5 Jun 12 10:32 dira/five
36885    4 -rw-r--r--  1 user      staff            6 Jun 12 10:32 dirb/three
36884    4 -rw-r--r--  1 user      staff            4 Jun 12 10:32 dirc/two
36886    4 -rw-r--r--  1 user      staff            5 Jun 12 10:32 dirc/four


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top