Operating System - HP-UX
1833300 Members
2951 Online
110051 Solutions
New Discussion

Re: link directories (share information between 2 dir in the same system)

 
SOLVED
Go to solution
Inter_1
Frequent Advisor

link directories (share information between 2 dir in the same system)

Hi,

I have 2 directories that should have the same information.

/test1
/test2

everytime that i restart the application the files in dir /test1 are updated. I want that also to have the same files in /test2.

Example
if in the dir /test1 I have the following files
the same information I want in the /test2
/test1
file1 file2

/test2
file1 file2

How can I do that?

Thanks
Andy
I like to fix things.
6 REPLIES 6
Peter Godron
Honored Contributor

Re: link directories (share information between 2 dir in the same system)

Andy,
"man ln" will provide the answer
ln -s /test1 /test2

spex
Honored Contributor

Re: link directories (share information between 2 dir in the same system)

Hi Andy,

$ mkdir test1
$ touch test1/file1 test1/file2
$ ls test1
file1 file2
$ ln -s test1 test2
$ ls -F
test1/ test2/
$ ls -L test2
file1 file2

PCS
Inter_1
Frequent Advisor

Re: link directories (share information between 2 dir in the same system)

I dont see the the same files on both dirs

root@app06 # cd ../test1
root@app06 # touch file1
root@app06 # touch file2
root@app06 # touch file3
root@app06 # ls -ltr /test1/
total 0
-rw-r--r-- 1 root other 0 Jan 9 14:53 file1
-rw-r--r-- 1 root other 0 Jan 9 14:53 file2
-rw-r--r-- 1 root other 0 Jan 9 14:53 file3
root@app06 # ls -ltr /test2/
total 2
lrwxrwxrwx 1 root other 5 Jan 9 14:52 test1 -> test1
root@app06 # ls -ltr /test2/

Thanks
I like to fix things.
James R. Ferguson
Acclaimed Contributor
Solution

Re: link directories (share information between 2 dir in the same system)

Hi Andy:

# cat .mytest
#!/usr/bin/sh
mkdir /tmp/test1
mkdir /tmp/test2
touch /tmp/test1/file1 /tmp/test1/file2 /tmp/test1/file3
ln -s /tmp/test1/file1 /tmp/test1/file2 /tmp/test1/file3 /tmp/test2
ls -l /tmp/test1
ls -l /tmp/test2

...run:

# ./mytest
/tmp/test1:
total 0
-rw-r----- 1 root sys 0 Jan 9 16:22 file1
-rw-r----- 1 root sys 0 Jan 9 16:22 file2
-rw-r----- 1 root sys 0 Jan 9 16:22 file3

/tmp/test2:
total 0
lrwxr-x--- 1 root sys 16 Jan 9 16:22 file1 -> /tmp/test1/fi
le1
lrwxr-x--- 1 root sys 16 Jan 9 16:22 file2 -> /tmp/test1/fi
le2
lrwxr-x--- 1 root sys 16 Jan 9 16:22 file3 -> /tmp/test1/fi
le3

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: link directories (share information between 2 dir in the same system)

> have 2 directories that should have the same information.

The ln -s solutions don't do that exactly. What they do is make it seem that one directory has two names. You only have one copy of everything. Is this what you want?

>I dont see the the same files on both dirs

You have created a link from test1 to test1, in test2.

You need to do what Peter and PCS said.

>JRF: ln -s /tmp/test1/file1 /tmp/test1/file2 /tmp/test1/file3 /tmp/test2

You may not want to use absolute paths for symlinks. They don't work if you mounting the filesystem over NFS.

Instead use relative links. It is easier to be in /tmp/test2 for this:

ln -s ../test1/* .

I.e. you can push absolute links but you want to pull relative links created by file name completion.
Yogeeraj_1
Honored Contributor

Re: link directories (share information between 2 dir in the same system)

hi,

as long as you are sharing the directories within the same system, there should not be any problem using the full path for specifying the paths.

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)