Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Suppose I have a folder foo with the two content:

data1.txt
cfg.txt

Now I create a new symlink called fo2 which points to directory foo:

cp -s -R /home/user123/foo /home/user123/fo2

It's working okay. But then, I try to made new files in foo folder, say data2.txt. When I opened fo2 folder, it only contains a symlink to data1.txt and cfg.txt data2.txt doesn't exist.

How to make the content of fo2 folder automatically synced with with foo so data2.txt automatically appears in fo2?

ln -s is not an option because I want the content of cfg.txt in foo and fo2 folder to be different. If I use copy -s -R, later I just come inside fo2 folder, delete cfg.txt symlink and recreate a real cfg.txt with different content.

share|improve this question
1  
Do you really want to symlink the content of the directory, or the directory itself? To me, it sounds like ln -s /home/user123/foo /home/user123/fo2 is what you want. –  htorque Feb 29 '12 at 8:59
    
I want to symlink both. If I use ln -s and opened fo2 folder, it will have 1.txt and 2.txt of actual folder, while I want the content of 1.txt in foo and fo2 folder to be different (for example, configuration files). If I use cp -s -R, I can open fo2 folder, delete 1.txt symlink and recreate a new 1.txt with different content –  Asker Feb 29 '12 at 9:03

1 Answer 1

If the locations are both on the same filesystem, you should use hard links. Otherwise, you'll have to setup some sort of synchronization, but that will be extremely inefficient in comparison.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.