Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 May 2011 05:30:02 -0400
From:      "b. f." <bf1783@googlemail.com>
To:        utisoft@gmail.com
Cc:        freebsd-questions@freebsd.org, Modulok <modulok@gmail.com>
Subject:   Re: Piping find into tar...
Message-ID:  <BANLkTike2NRiY33p1epo0hiz_SbgvGma6g@mail.gmail.com>
In-Reply-To: <BANLkTikxNouAi7SQ0xEEK+jGFZzRH=r3TQ@mail.gmail.com>
References:  <BANLkTi=-90CJk41um5A3J-iSEVUCv1Viqg@mail.gmail.com> <BANLkTikxNouAi7SQ0xEEK+jGFZzRH=r3TQ@mail.gmail.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On 5/4/11, Chris Rees <utisoft@gmail.com> wrote:
> On 4 May 2011 08:44, b. f. <bf1783@googlemail.com> 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.



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?BANLkTike2NRiY33p1epo0hiz_SbgvGma6g>