Date: Fri, 8 Mar 2002 08:41:14 +0100 From: F.Xavier Noria <fxn@isoco.com> To: "Jon Larssen" <jonlarssen@hotmail.com> Cc: freebsd-questions@FreeBSD.org Subject: Re: find(1) usage Message-ID: <20020308084114.4f110253.fxn@isoco.com> In-Reply-To: <F169kAvjUqMUrYawLLe00013a42@hotmail.com> References: <F169kAvjUqMUrYawLLe00013a42@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 08 Mar 2002 05:56:02 +0000 "Jon Larssen" <jonlarssen@hotmail.com> wrote: : Now, I'd like to use the -exec expression of find(1) to obtain the following : (sample) command: : : cp -p /etc/master.passwd backup/etc/master.passwd : : I know there's a thingy, {}, that would give the whole path : (backup/etc/master.passwd, for instance). Now, how can I erase the backup : part? Is this doable just with clever use of find(1)? Not clever, but seems to work :-): $ find backup/ -name '*' -exec \ perl -e '$cur = $bak = shift; $cur =~ s,[^/]*,,; system qq(cp -p "$cur", "$bak")' \ {} \; I prefer not to use -exec when it is not acting as a filter: $ find backup/ -name '*' | perl -ne \ '$cur = $bak = $_; $cur =~ s,[^/]*,,; system qq(cp -p "$cur", "$bak")' -- fxn To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020308084114.4f110253.fxn>