The file that grew in size in the example above was fairly random. The content of a file plays a large role in how well it will compress. If you see a message like this after compressing a file, you're not gaining much. If compression increases the size of a file or reduces its size by some very small percentage, the only benefit may be that you may have a convenient online backup. Note that the compressed version of the file (bigfile.zip) is actually a little larger than the original file. While this isn't generally the case, it can happen - especially when the file content approaches some degree of randomness. In the example below, the "compressed" file is actually larger than the original. Sometimes the time and effort of compressing a file doesn't pay off very well. All of those commands work in similar ways, but there are some tradeoffs in terms of how much the file content is squeezed (how much space you save), how long the compression takes, and how compatible the compressed files are with other systems you might need to use them on. The commands most commonly used for file compression on Linux systems include zip, gzip, bzip2 and xz. Compression algorithms are far more complex and have only been getting more so since compression was first introduced in the toddler years of Unix. How is that done? It's easy to imagine how 300 of the same character in a row could be compressed to something like "300X," but this type of algorithm wouldn't be of much benefit for most files because they wouldn't contain long sequences of the same character any more than they would completely random data. In other words, they have to be lossless. But algorithms used on the Linux command line to compress or archive user files have to be able to reproduce the original content exactly. Some compression tools are "lossy," such as those used to reduce the size of mp3 files while allowing listeners to have what is nearly the same musical experience as listening to the originals. On my Ubuntu system, over 60 commands were listed in response to the apropos compress command.Ĭompression is not a one-size-fits-all issue. $ apropos compress | grep ^bzīzcmp (1) - compare bzip2 compressed filesīzdiff (1) - compare bzip2 compressed filesīzegrep (1) - search possibly bzip2 compressedīzexe (1) - compress executable files in placeīzfgrep (1) - search possibly bzip2 compressedīzgrep (1) - search possibly bzip2 compressedīzip2 (1) - a block-sorting file compressor,īzless (1) - file perusal filter for crt viewingīzmore (1) - file perusal filter for crt viewing Add in zip, gzip, and xz, and you've got a lot of interesting options. You're likely to see all of these entries just for the suite of bzip2 compression commands. Chances are you'll be surprised by the many commands that you can use for compressing and decompressing files, as well as for comparing compressed files, examining and searching through the content of compressed files, and even changing a compressed file from one format to another (i.e. If you have any doubt about the many commands and options available on Linux systems for file compression, you might want to take a look at the output of the apropos compress command.
0 Comments
Leave a Reply. |