how to recursively symlink every file in a dir

Arthur Chance freebsd at qeng-ho.org
Thu Sep 9 18:01:53 UTC 2010


On 09/09/10 18:50, Arthur Chance wrote:
> On 09/09/10 18:24, Aryeh Friedman 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:
>
> cpio -pdl

Ack! Too quick to answer. That hard links, not symlinks. (Useful in its 
own way though.)

cd $SRCDIR; find . -type d | cpio -pd $DESTDIR

will create the directory structure. Linking the files will have to be 
left as an exercise for the reader as I have to go out. I'd use find for 
the job, but I'm sure someone will come up with some Perl.


More information about the freebsd-questions mailing list