how to recursively symlink every file in a dir

Aryeh Friedman aryeh.friedman at gmail.com
Thu Sep 9 17:46:58 UTC 2010


I want to make it so every file is a seperate symlink in dir2 if and
only if it is a regular file (not a dir) in dir1... the reason is if
the file is unchanged then use symlink but I can rm the symlink and
replace it with a non-symlink:

To show the problem I am attempting to solve:

foo: (owned by fred)
    arf:
       ack

in barney's account:

ln -s ~foo/ foo
rm foo/arf/ack    # Permissioin denied ... it should nuke the symlink
and let me then do something like "touch foo/arf/ack

Note there are over 500 files upto 5 dirs deep in the dir I want to
symlink from.... the final application is our version control system
(devel/aegis) keeps seperate repos for different source code projects
(for obvious reasons) and we want to make it so in normal operation we
can symlink tne source tree from one project into an other but if we
want to make a local modificiation to the "foreign" source tree all we
have do is (sorry for the aegis commands but I think the idea is
clear):

rm src/foreign/foo.c
aenf src/foreign/foo.c
cp ~aegis/foreign/baselins/src/forgein.c
vi src/foreign/foo.c   # to make local modifications

And before someone suggests a ar library we purposely *DO NOT* want
the modified libs to be installed until later


More information about the freebsd-questions mailing list