[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Howto?



Hi,

Gene Heskett wrote:
> But xz is rejecting directories,
> like it expects tars output as its input.

It expects data files or a data stream.


> I want to compress the directory foo into foo.xz, keeping foo as there
> may be further patches applied in the future.

If you want to compress the tree of files of a directory as a whole, then
you need to represent this tree as a single data file. For being
convertable back to a file tree, this representation needs to mark the
tree files by name, position, size, and metadata.
The usual method to do this is to pack up the tree in an archive file
and to compress that file.

Typical archivers are tar, cpio, zip, but also any filesystem that can be
represented as image file. If packing and compression shall be done in
one sweep, then the archiver has to able to put out its result as a data
stream, which you then pipe into the compressor.


> Syntax?

Consider

  tar cf - "$DIRECTORY" | xz > "$DIRECTORY".tar.xz

or if you want a directory tree of compressed data files

  cp -a "$DIRECTORY" "$DIRECTORY"_with_xz
  find "$DIRECTORY"_with_xz -not -name '*.xz' -type f -exec xz '{}' ';'

Have a nice day :)

Thomas


Reply to: