Symlink a directory and automatically sync its content
Suppose I have a folder foo with the two content:
data1.txt
cfg.txtNow I create a new symlink called fo2 which points to directory foo:
cp -s -R /home/user123/foo /home/user123/fo2It'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.
1 Answer
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.