In windows by default one can see the compression ratio of zip files and after installing WinRAR it also supports this feature but currently I am using a linux and have compressed a file using lzma2 and xz as the container but how can I check the compression ratio without comparing the original file size and the compressed file size? Is it even possible?
Ny way to check the compression ratio of a xz compressed file
archivecompressiontarxz
Related Solutions
You cannot improve the compression ratio, without decompressing the data. You don't have to extract all of the zip files before compressing them, but I would recommend uncompressing one whole zip file before re-compressing.
It is possible to recompress the files in a zip file one at a time and re-adding them before going to the next file contained in the zip file. This requires N rewrites of the zip file for a zip file containing N files. It is much more efficient to extract the N files and generate the new zipfile in one go, compressing all files with -9
.
It is not possible to update or delete files from a solid compression. In a solid compression, the compression of the subsequent data depends on statistical analysis of previous data (which usually brings better compression fine tuning the statistical analysis of the input), hence removing files require un-compression and re-compression of the whole archive containing the files.
It is also important to understand that solid compression is usually used where you want to save disk/bandwidth but don't mind the extra time it takes to compress or decompress and loose the flexibility of updating or editing. there are other tools out there that provide the ability for quick compression/decompression, including updating existing archive but then the compression ratio is not the same as solid compression.
The Solid compression you are referring to "tar.xz" is an "emulated" solid compression"
In computing, solid compression refers to a method for data compression of multiple files, wherein all the uncompressed files are concatenated and treated as a single data block. Such an archive is called a solid archive. It is used natively in the 7z [1] and RAR [2] formats, as well as indirectly in tar-based formats such as .tar.gz and .tar.bz2. By contrast, the ZIP format is not solid because it stores separate compressed files (though solid compression can be emulated for small archives by combining the files into an uncompressed zip archive and then compressing the zip archive inside a second compressed zip file).
Let me start by explaining how your currently used method of tar.xz works.
tar
In computing, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball
Hence Tar is basically an archive.
xz
xz is a lossless data compression program and file format which incorporates the LZMA/LZMA2 compression algorithms. it has a high compression ratio, however slow compression and decompression times.
Hence when you combine the two you are first Archiving (tar) a number of files and then compressing (xz) that single file.
Now on the question on how can one add new content / update the existing compressed file.
If using tar.xz you will have to uncompress the tar.xz, which will leave you with a tar file and then you can use the following to append the archive.
tar --append --file=archive.tar file_or_dir_to_add
and then to compress it back again.
xz archive.tar
Or alternatively, you can use ZIP.
zip -g archive.zip folder/file
ZIP is an archive file format that supports lossless data compression. A .ZIP file may contain one or more files or directories that may have been compressed. The .ZIP file format permits a number of compression algorithms, though DEFLATE is the most common.
Best Answer
Yes, just type in a shell terminal