0

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.

2
  • 3
    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, 2012 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, 2012 at 9:03

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .