From owner-freebsd-questions@FreeBSD.ORG Thu Sep 9 20:05:50 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B90F10656A4 for ; Thu, 9 Sep 2010 20:05:50 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id BCF898FC08 for ; Thu, 9 Sep 2010 20:05:46 +0000 (UTC) X-Spam-Status: No X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-1.5, required 5, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_05 -0.50) X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-ID: o89JmxUU005335 Received: from kobe.laptop (79.103.63.75.dsl.dyn.forthnet.gr [79.103.63.75]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-9.2) with ESMTP id o89JmxUU005335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 9 Sep 2010 22:49:06 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.4/8.14.4) with ESMTP id o89JmsxD098249 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 9 Sep 2010 22:48:54 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.4/8.14.4/Submit) id o89JmrMX098235; Thu, 9 Sep 2010 22:48:53 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Aryeh Friedman References: Date: Thu, 09 Sep 2010 22:48:53 +0300 In-Reply-To: (Aryeh Friedman's message of "Thu, 9 Sep 2010 13:24:50 -0400") Message-ID: <87bp86r93u.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain Cc: FreeBSD Mailing List Subject: Re: how to recursively symlink every file in a dir X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Sep 2010 20:05:50 -0000 On Thu, 9 Sep 2010 13:24:50 -0400, 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: > > 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