From owner-freebsd-questions@FreeBSD.ORG Thu Aug 21 13:17:08 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 CA92A1065686 for ; Thu, 21 Aug 2008 13:17:08 +0000 (UTC) (envelope-from thavinci@thavinci.za.net) Received: from thavinci.za.net (thavinci.za.net [196.211.117.42]) by mx1.freebsd.org (Postfix) with ESMTP id 4CFEF8FC1E for ; Thu, 21 Aug 2008 13:17:08 +0000 (UTC) (envelope-from thavinci@thavinci.za.net) Received: from thavinci.za.net (localhost.thavinci.za.net [127.0.0.1]) by thavinci.za.net (Postfix) with ESMTP id 751C41EEAFB for ; Thu, 21 Aug 2008 15:17:06 +0200 (SAST) Received: from thavinciPC (unknown [192.168.12.110]) by thavinci.za.net (Postfix) with ESMTP id 51BBA1EEAFA for ; Thu, 21 Aug 2008 15:17:06 +0200 (SAST) From: "Marcel Grandemange" To: References: <014d01c90387$c6ed2b70$54c78250$@za.net> <200808211241.m7LCfaw3096717@lurza.secnetix.de> In-Reply-To: <200808211241.m7LCfaw3096717@lurza.secnetix.de> Date: Thu, 21 Aug 2008 15:16:45 +0200 Message-ID: <015a01c90390$28f81250$7ae836f0$@za.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AckDi0UEvzETCStfTq2yCjEQuevujAABM31w Content-Language: en-us X-Virus-Scanned: ClamAV using ClamSMTP Cc: Subject: RE: Copying a directory tree (was: xargs) 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, 21 Aug 2008 13:17:08 -0000 Thank you all! And im on my way thanks to greate response! -----Original Message----- From: Oliver Fromme [mailto:olli@lurza.secnetix.de]=20 Sent: Thursday, August 21, 2008 2:42 PM To: freebsd-questions@FreeBSD.ORG; thavinci@thavinci.za.net Subject: Copying a directory tree (was: xargs) 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 --=20 Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. = M. Handelsregister: Registergericht Muenchen, HRA 74606, = Gesch=E4ftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht = M=FCn- chen, HRB 125758, Gesch=E4ftsf=FChrer: 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 __________ NOD32 3372 (20080820) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com