From owner-freebsd-questions@FreeBSD.ORG Thu Aug 21 12:41:39 2008 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 32C9B1065672 for ; Thu, 21 Aug 2008 12:41:39 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 9AEF18FC25 for ; Thu, 21 Aug 2008 12:41:38 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.2/8.14.2) with ESMTP id m7LCfaKh096718; Thu, 21 Aug 2008 14:41:36 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.2/8.14.2/Submit) id m7LCfaw3096717; Thu, 21 Aug 2008 14:41:36 +0200 (CEST) (envelope-from olli) Date: Thu, 21 Aug 2008 14:41:36 +0200 (CEST) Message-Id: <200808211241.m7LCfaw3096717@lurza.secnetix.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG, thavinci@thavinci.za.net In-Reply-To: <014d01c90387$c6ed2b70$54c78250$@za.net> X-Newsgroups: list.freebsd-questions User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.3-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Thu, 21 Aug 2008 14:41:37 +0200 (CEST) Cc: Subject: Copying a directory tree (was: xargs) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-questions@FreeBSD.ORG, thavinci@thavinci.za.net List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 12:41:39 -0000 Marcel Grandemange wrote: > I need to copy an entire BSD installation except > the /mnt directory to /mnt/pc You don't need xargs for this. # cd / # find -Ed . -regex '\./(mnt|dev)' -prune -or -print0 | cpio -dump0 /mnt/pc If you have procfs mounted, add "|proc" to the regex, or simply umount it before. It's not required for anything important. Or -- slightly less efficient, but this might be better if you're more familiar with grep than with find: # cd / # find -d . | egrep --null -v '^\./(mnt|dev)/' | cpio -dump0 /mnt/pc Yet another way is to use cpdup (from ports/sysutils/cpdup): # echo mnt > .cpignore # cpdup -x / /mnt/pc Note that cpdup doesn't cross mountpoints, so you don't have to exclude dev or proc. But you will have to repeat the command for /var, /usr, /tmp or any other directories that are on separate file systems. > Ls | grep -v proc | xargs cp -Rpv /mnt/pc Do not use cp -R or cp -r. It has several problemsm, for example it breaks hardlinks. In my opinion the -R and -r options of cp(1) should be removed, or a big fat warning message should be printed, because they're abused most of the time and cause breakage that other people have to find and clean up afterwards. Been there, done that, a thousand times. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd Perl is worse than Python because people wanted it worse. -- Larry Wall