From owner-freebsd-questions@FreeBSD.ORG Wed May 4 09:30:02 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 DAD8F106564A for ; Wed, 4 May 2011 09:30:02 +0000 (UTC) (envelope-from bf1783@googlemail.com) Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id A972D8FC18 for ; Wed, 4 May 2011 09:30:02 +0000 (UTC) Received: by pwj8 with SMTP id 8so573506pwj.13 for ; Wed, 04 May 2011 02:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=b16cHdyGr6JVetKGudFll/HM432ut5LBCRK8mpCbY8k=; b=NXzspqaamBF422N5TzNCiW6ha1e9KVvimvimAfE8aQmnoEwJNZuNNR+Ogmkrq+Im3Q bAqjh2vcle89+ZK832EnMXGN4vQkKWrKtf9J+VwCzHIcVKK3aiVYATsD1Xbl2lh2ZyuW cCYRxR8GD26068XHAiDclg/NfaLVUsxueOxjE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; b=xX/SqQnOdMY3wbT201sYbwtUPLmbtuJv9v1acmx+XSwOrGf/8oF0LLJDuQV6C6Kqva /trQAUTDPT+ELpSo3mxoJ2YhEjYmlDLkAErHW/qTWm94PYRDArC8YkBs5yy88FBQ+KOU RN5WpUWMXR7OYExxPFGNO9v4ivWUv+wt1eVp8= MIME-Version: 1.0 Received: by 10.68.26.134 with SMTP id l6mr1368561pbg.50.1304501402054; Wed, 04 May 2011 02:30:02 -0700 (PDT) Received: by 10.68.55.136 with HTTP; Wed, 4 May 2011 02:30:02 -0700 (PDT) In-Reply-To: References: Date: Wed, 4 May 2011 05:30:02 -0400 Message-ID: From: "b. f." To: utisoft@gmail.com Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-questions@freebsd.org, Modulok 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 09:30:03 -0000 On 5/4/11, Chris Rees wrote: > On 4 May 2011 08:44, b. f. wrote: >>> I've been playing with the find command lately. Is there a way I can pipe >>> the >>> putput list of files from find, into the tar command to create an archive >>> which >>> contains the files which find lists? I tried the following, but it didn't >>> work >>> (obviously). >>> >>> find -E . '.*\.txt$' -print | tar -cjf result.tgz >> >> You could use something like: >> >> find -X . -name '*.txt' | xargs tar -cjf result.tgz >> >> or >> >> find . -name '*.txt' -print0 | xargs -0 tar -cjf result.tgz >> >> b. > > How about using pax? > > find . -depth -print | pax -wd | gzip > archive.tgz > > or > > find . -depth -print | pax -wd | bzip2 > archive.tbz > > > By the way, in reference to the commands above the -j option is for > bzip2, so the extension should be .tbz o_O True. I just reproduced what the OP had. The archive will still use bzip2 compression, and bsdtar won't have a problem handling it, but the name will be misleading. As you wrote, pax(1) is an option, as are cpio(1) and many others... You should be able to use -z with pax to avoid the extra pipe and explicit invocation of gzip in the first case. b.