Re: Piping find into tar...



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.
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Piping find into tar...
    ... space characters in filenames. ... (Thanks for the correction on the extenion. ... When the amount of files is huge then tar will be invoked twice ...
    (freebsd-questions)
  • Re: Piping find into tar...
    ... (Thanks for the correction on the extenion. ... As for pax, I thought tar could create pax archives too, via the --format ... Pax makes tar by default-- It's a great way to make tars with cpio syntax. ...
    (freebsd-questions)
  • Re: find... tar.. gzip...
    ... Find will execute a separate 'tar cvf' for each of the files found, ... also allows creating new archives with "r"; so, a minimal correction ... could be to use rvf instead of cvf in the above tar command. ...
    (comp.unix.shell)
  • Re: Piping find into tar...
    ... Dne 4.5.2011 14:37, b. ... Thus result.tbz will contain just files from the last invocation. ... I consider cpio a better option here. ... one could still use find and tar in many cases by ...
    (freebsd-questions)
  • Re: how to find the extension of a file?
    ... > The following mechanism will yeild the extension, ... This only shows tar ... Correction: ...
    (comp.unix.shell)