From owner-freebsd-questions@FreeBSD.ORG Wed May 4 13:09:01 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 C45ED106566B for ; Wed, 4 May 2011 13:09:01 +0000 (UTC) (envelope-from kron24@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 486F18FC08 for ; Wed, 4 May 2011 13:09:00 +0000 (UTC) Received: by fxm11 with SMTP id 11so1082719fxm.13 for ; Wed, 04 May 2011 06:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=x1netcC82OlIgODm2XbDNcjOy57DgTOPmooBkuRHSNQ=; b=xivhjWhUBcTgiSk8EcHhz4eysBV3CQBTUlHJBouUdkZLaF9LHTd58HT2A8PDA+NIdn C6jVnRRp2pUhpsKu2h7HDbUKF8dsGnptwr+xhAEB24PjyPEHVQQexX3y37GPlxPHZGe+ bMJDG7fs6VUvPNFPuV5LmwSS7jPAi0Lvx86R0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=oUjSgPfa55d8NY/rsRjHUJRNf/rOgBmz5+JoLv9oqbynMZwEivb4P7ZlIMM4icEn+N mSmduS9jaTJW3LJ0rNjlYBOwzQEvTe35QiJIlRzNmd+TfcjVBZv34I3vvojgjvWIq1Nm JMTvSaCAzUulfi1vP6v0Yj5aZP1tgiAoSDt2I= Received: by 10.223.145.78 with SMTP id c14mr1254802fav.75.1304514540071; Wed, 04 May 2011 06:09:00 -0700 (PDT) Received: from [192.168.1.3] (uidzr185142.sattnet.cz [212.96.185.142]) by mx.google.com with ESMTPS id n7sm390847fam.11.2011.05.04.06.08.57 (version=SSLv3 cipher=OTHER); Wed, 04 May 2011 06:08:58 -0700 (PDT) Message-ID: <4DC14FE8.2080207@gmail.com> Date: Wed, 04 May 2011 15:08:56 +0200 From: kron24 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110421 Fedora/3.1.9-2.fc14 Thunderbird/3.1.9 MIME-Version: 1.0 To: bf1783@googlemail.com References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 May 2011 13:09:01 -0000 Dne 4.5.2011 14:37, b. f. napsal(a): >> Dne 4.5.2011 11:42, Modulok napsal(a): ... >>> 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 Yes, this would work, of course. Anyway, I prefer to use "find ... | cpio ... | bzip2 ...". I just disputed Modulok's solution "find ... | xargs tar -cjf ..." which wouldn't work in some cases. BR, Oli