From owner-freebsd-questions@FreeBSD.ORG Wed May 4 14:25:00 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 545041065672 for ; Wed, 4 May 2011 14:25:00 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id CB2E08FC1B for ; Wed, 4 May 2011 14:24:59 +0000 (UTC) Received: by bwz12 with SMTP id 12so1456305bwz.13 for ; Wed, 04 May 2011 07:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=GgBuZHzJBIj5EPyHyv4qaCdwHUgzRULR8YBibylywbg=; b=iJM6C7ouWRpXifKgt9RxPZXAJG7CBWnlSWBZhhQlS43CMu0frpYrLCDJOcwF3l6dB3 /X4C2448IP+EHSaqHoAYy/T74XOS0olA7pCuwWwBMOJ+H4KRPCyyPt0BUXNjWas/6uwl mkkt5uEe7fGBPo0Bmgu3hrs+fEqCkQ8l2AjCc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; b=ejeotj+w4qklRDSn7x3JteS4+XWhzygUiACd13lf2hboFaaZ2NJ2P5/XYwajNw29Xu G6IKhFVdjJHAfzJduDSVxwZInokqMLtTYNjZZNRVnHkUXcootmQYVFXcaZljEE34BTC4 8eaAsK+tl93qcry//6hybk3YGl5VUDOQk1RJY= MIME-Version: 1.0 Received: by 10.204.231.198 with SMTP id jr6mr1098070bkb.205.1304519098682; Wed, 04 May 2011 07:24:58 -0700 (PDT) Received: by 10.204.42.21 with HTTP; Wed, 4 May 2011 07:24:58 -0700 (PDT) Received: by 10.204.42.21 with HTTP; Wed, 4 May 2011 07:24:58 -0700 (PDT) In-Reply-To: <44r58ey4xl.fsf@lowell-desk.lan> References: <4DC13794.6010004@gmail.com> <44r58ey4xl.fsf@lowell-desk.lan> Date: Wed, 4 May 2011 15:24:58 +0100 Message-ID: From: Chris Rees To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: kron24 , Modulok Subject: Re: Piping find into tar... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: utisoft@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2011 14:25:00 -0000 On 4 May 2011 14:25, "Lowell Gilbert" < freebsd-questions-local@be-well.ilk.org> wrote: > > 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. > Why on Earth are people still fooling about contorting tar into weird shapes???? The great thing about pax is It's a drop in replacement for cpio that makes tar archives; It's designed to be used with find! Chris