Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 May 2011 15:08:56 +0200
From:      kron24 <kron24@gmail.com>
To:        bf1783@googlemail.com
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Piping find into tar...
Message-ID:  <4DC14FE8.2080207@gmail.com>
In-Reply-To: <BANLkTimObcwyA7z%2BG1MjeE4UXsuyK4rsLg@mail.gmail.com>
References:  <BANLkTimObcwyA7z%2BG1MjeE4UXsuyK4rsLg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DC14FE8.2080207>