Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use tar with lz4?

How to use tar and filter the archive through LZ4? Or any available tools? It looks cumbersome to use tar cvf folderABC.tar folderABC && lz4c -c0 folderABC.tar.

PS: *nix environment

like image 829
Daniel Avatar asked Jun 05 '14 15:06

Daniel


People also ask

How do you untar a lz4?

Similarly, lz4 -m -d can decompress multiple *. lz4 files. It's possible to opt-in to erase source files on successful compression or decompression, using --rm command. Consequently, lz4 -m --rm behaves the same as gzip .

What is lz4 command?

Description. lz4 is an extremely fast lossless compression algorithm, based on byte-aligned LZ77 family of compression scheme. lz4 offers compression speeds of 400 MB/s per core, linearly scalable with multi-core CPUs.

What is tar XF command?

The most common uses of the tar command are to create and extract a tar archive. To extract an archive, use the tar -xf command followed by the archive name, and to create a new one use tar -czf followed by the archive name and the files and directories you want to add to the archive.


3 Answers

On GNU tar, you can use -I lz4

Both FreeBSD and GNU tar seems to support --use-compress-program=lz4 as well.

tar -I lz4 -cf archive.tar.lz4 stuff to add to archive
tar -I lz4 -xf archive.tar.lz4

or

tar --use-compress-program=lz4 -cf archive.tar.lz4 stuff to add to archive
tar --use-compress-program=lz4 -xf archive.tar.lz4
like image 194
Gert van den Berg Avatar answered Oct 25 '22 22:10

Gert van den Berg


lz4 has a command line structure similar to gzip. Therefore, something like this will work :

tar cvf - folderABC | lz4 > folderABC.tar.lz4

or

tar cvf - folderABC | lz4 - folderABC.tar.lz4

First one compresses silently, like gzip. Second one is a bit more lz4-specific, and will also display summarized compression stats.

like image 45
Cyan Avatar answered Oct 26 '22 00:10

Cyan


To use -I in GNU tar, you must specify it AFTER destination file as this:

tar cvf /path/to/destinationfile.tar.lz4 -I lz4 /path/to/archive
like image 28
JTerry Avatar answered Oct 25 '22 23:10

JTerry