From owner-freebsd-questions@FreeBSD.ORG Wed May 4 12:37:25 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 E4C8B106564A for ; Wed, 4 May 2011 12:37:25 +0000 (UTC) (envelope-from bf1783@googlemail.com) Received: from mail-px0-f176.google.com (mail-px0-f176.google.com [209.85.212.176]) by mx1.freebsd.org (Postfix) with ESMTP id B327E8FC0C for ; Wed, 4 May 2011 12:37:25 +0000 (UTC) Received: by pxi11 with SMTP id 11so774491pxi.7 for ; Wed, 04 May 2011 05:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:date:message-id:subject :from:to:cc:content-type; bh=XqjRFH4NknuRKC+eZLcSe4APzyAK5y9y73oYP5JHYVU=; b=GsPLxKIQhX+MNGlcMYwtSFZpJOvajErvAu1cvJZ57urR5yWh/qzBaWZxyHlCg+CAHY OHksPyA2VUURi+Fczk/urxM2qUffYdJH+gXLp6PTAccD63FBnX0Big13Z/gYCBucWjcX XbxhIl/rrg2qvkz5Mg08puzQSZUMnMca5HUuE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:date:message-id:subject:from:to:cc :content-type; b=KxRIJu0YXU3QywwQcPjy9vkpiktmC3M9GyMv+ivBg4O0IsBfs8+igsOJ7z5AF/lNHp uqF9ikjaeACp4FSyEs/6sRmAm168XO49siqa7oXLPErk/ZFwlDEpuSOG6YYyePI1R+a8 ISwv2L+MT0LzGI9vEkGLxpcVTqSh1fnuTPafk= MIME-Version: 1.0 Received: by 10.68.60.67 with SMTP id f3mr1512058pbr.318.1304512645131; Wed, 04 May 2011 05:37:25 -0700 (PDT) Received: by 10.68.55.136 with HTTP; Wed, 4 May 2011 05:37:24 -0700 (PDT) Date: Wed, 4 May 2011 08:37:24 -0400 Message-ID: From: "b. f." To: kron24 Content-Type: text/plain; charset=ISO-8859-1 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: bf1783@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2011 12:37:26 -0000 > 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. > > I consider cpio a better option here. The use of simple patterns permitted by tar(1) or cpio(1) may be a good choice in some cases, but we were responding to the OP's wish to use find(1), which is a bit more flexible. If there were a large number of files, one could still use find and tar in many cases by appending to the archive rather than (re)creating it with each tar invocation, e.g.: find . -type f -name '*.txt' -print0 | xargs -0 tar -rvf archive.tar ; bzip2 archive.tar b.