Asked something similar a while ago in Unix&Linux but got yelled at, so will try again...
Let me take a directory called DIR
with the structure
DIR/
|----> file1.txt
|----> file2.txt
|----> file3.txt
|----> SUB_DIR/
|-----> file4.txt
What I want to do is create another directory whose contents would be symbolic links to the files and directories in DIR
. That is, denoting symlinks by ** name **
LINKED_DIR/
|----> **file1.txt**
|----> **file2.txt**
|----> **file3.txt**
|----> **SUB_DIR**/
|-----> **file4.txt**
From previous suggestions, I've been able to do this via GNU Stow
:
stow DIR -t LINKED_DIR
what happens is that file_{1,2,3}.txt
in LINKED_DIR are turned into symlinks to the corresponding file in DIR
, and SUB_DIR
appears as a symlink to the corresponding directory in DIR
, but the files inside are not symlinks:
LINKED_DIR/
|----> **file1.txt**
|----> **file2.txt**
|----> **file3.txt**
|----> **SUB_DIR**
$ls LINKED_DIR/**SUB_DIR**
file4.txt
What I would further like to do is make sure that when a file is added to DIR/, the mirror directory LINKED_DIR/ updates with a symbolic link to the new file. This does not work with the setup as described, e.g. creating DIR/file5.txt
does not lead to the symlink DIR/**file5.txt**
, and creating DIR/SUB_DIR/file6.txt
leads to a copy/the same file (not a symlink) appearing in LINKED_DIR/**SUB_DIR**
Has anyone found a solution to this?
I'd like to replicate the relationship between /usr/bin
and bin
, where the contents in bin
are linked to the contents in /usr/bin
, and changes (e.g. the addition of new files) are automatically reflected.
bin
setup, thought I would revisit this.