From owner-freebsd-questions@FreeBSD.ORG Wed May 4 13:24:30 2011 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 8664C1065670 for ; Wed, 4 May 2011 13:24:30 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from mail1.sea5.speakeasy.net (mail1.sea5.speakeasy.net [69.17.117.39]) by mx1.freebsd.org (Postfix) with ESMTP id 5B90A8FC15 for ; Wed, 4 May 2011 13:24:30 +0000 (UTC) Received: (qmail 10615 invoked from network); 4 May 2011 13:24:29 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail1.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 4 May 2011 13:24:29 -0000 Received: from lowell-desk.lan (lowell-desk.lan [172.30.250.8]) by be-well.ilk.org (Postfix) with ESMTP id 791E15081F; Wed, 4 May 2011 09:24:23 -0400 (EDT) Received: by lowell-desk.lan (Postfix, from userid 1147) id A804039842; Wed, 4 May 2011 09:24:22 -0400 (EDT) From: Lowell Gilbert To: Modulok , kron24 References: <4DC13794.6010004@gmail.com> Date: Wed, 04 May 2011 09:24:22 -0400 In-Reply-To: <4DC13794.6010004@gmail.com> (kron's message of "Wed, 04 May 2011 13:25:08 +0200") Message-ID: <44r58ey4xl.fsf@lowell-desk.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-questions@freebsd.org Subject: Re: Piping find into tar... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-questions@freebsd.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2011 13:24:30 -0000 kron24 writes: > Dne 4.5.2011 11:42, Modulok napsal(a): >>>> By the way, in reference to the commands above the -j option is for >> bzip2, so the extension should be .tbz o_O >> >> Thanks everyone! I went with the following, because it works regardless of >> space characters in filenames. (Thanks for the correction on the extenion. It >> should indeed be 'tbz' when using the 'j' flag.) >> >> find -E . -regex '.*\.txt$' -print0 | xargs -0 tar -cjf result.tbz > > When the amount of files is huge then tar will be invoked twice > or more. Thus result.tbz will contain just files from the last invocation. Yes, xargs isn't part of the solution for this case unless you use the update mode to tar, which will be much slower. However, tar can read the file list from a file, which can be stdin if you want. The equivalent of the above command would be something like: find -E . -regex '.*\.txt$' -print0 | tar --null -T - -cjf result.tbz > I consider cpio a better option here. The old ways still work very well. But it's worth noting that on FreeBSD these days, cpio(1) and tar(1) are both implemented on the same library, so there are very few things that one can do but the other cannot.