Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 09 Sep 2010 22:48:53 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Aryeh Friedman <aryeh.friedman@gmail.com>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: how to recursively symlink every file in a dir
Message-ID:  <87bp86r93u.fsf@kobe.laptop>
In-Reply-To: <AANLkTimR9QehTjUrm%2B0CqRVAx=QHkgcfpygrJJfkhbmp@mail.gmail.com> (Aryeh Friedman's message of "Thu, 9 Sep 2010 13:24:50 -0400")
References:  <AANLkTimR9QehTjUrm%2B0CqRVAx=QHkgcfpygrJJfkhbmp@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 9 Sep 2010 13:24:50 -0400, Aryeh Friedman <aryeh.friedman@gmail.com> wrote:
> 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

If you don't mind creating the local directories in one run, and then
symlinking everything else, you can use something like:

    cd bar
    ( cd ~foo ; find . -type d ) | xargs mkdir -p
    ( cd ~foo ; find . \! -type d ) | while read fname ; do
            ln -s ~foo/"$fname" "$fname"
        done




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87bp86r93u.fsf>