![]() You might have to first install xz if you want to include it in the tests.This script can make the comparison easier, but will likely take a few minutes to complete. If you'd like to run some tests on your own, grab a large but replaceable file and compress it using each of the commands shown above – preferably using a new subdirectory. xz: xz -d bigfile.xz or unxz bigfile.xz.These commands would work for decompressing bigfile after the compression commands shown above were run. The commands for decompressing files are similar to those used to compress the files. The zip command creates a file which can be used (i.e., decompressed) on Windows systems as well as Linux and other Unix systems without having to install other tools which may or may not be available. Regardless of what permissions you have set on your original file, permissions for the compressed file will be based on your umask setting, except for bzip2 which retains the original file's permissions. For bigfile, the approximate times were: command run-timeĭecompression times are likely to be considerably smaller than compression times. ![]() The xz command seems to take more time than the other commands to encrypt the files. The bzip2, gzip and xz commands all replace the original files with compressed versions. The xz commands wins, ending up at only 13% the size of the original file, but all of these compression commands reduced the original file size quite significantly. The percentages represent how the compressed files compare with the original file. When compared, the various compression commands shown above yielded the following results. Compression rates will depend to some extent on the content of the files. This file is a large and fairly random text file. The stats shown below all relate to compressing the single file – bigfile – used in the example commands shown above. So, let's compare file size as well as some other issues to be considered when you make plans for how you want to compress your files. Most people have heard it said that "size isn't everything". rw-rw-r- 1 shs shs 13427236 Apr 15 17:30 bigfile.xzįor large files, you are likely to notice that xz takes longer to run than other compression commands, but the compression results are very impressive. Again, the original file is compressed in place. Like the two previous commands, you only need to supply the file name to the command. rw-rw-r- 1 shs shs 18115234 Apr 15 17:57 bigfile.bz2Ī relative newcomer to the compression command team, xz is a front runner in terms of how well it compresses files. rw-rw-r- 1 shs shs 21606751 Apr 15 17:57 bigfile.gzĪs with the gzip command, bzip2 will compress the file that you select "in place", leaving only the original file. In other words, the original file will be replaced by the encrypted file. Unlike the commands described above, gzip will encrypt the files "in place". You just type "gzip" followed by the name of the file you want to compress. The syntax is straightforward except that, as with tar, you have to remember that your original file should be the last argument on the command line. The zip command creates a compressed file while leaving the original file intact. $ tar cfz bin.tgz bin/* ^ ^ | +- files to include + new file zip To collect a number of files together and compress the resultant “tar ball” in one command, use the same basic syntax, but specify the files to be included as a group in place of the single file. You will be left with both the original file and the compressed file once the compression is complete. If you prefer, you can use the tar.gz extension which might make the character of the file a bit more obvious, but most Linux users will probably recognize tgz as meaning the same thing – the combination of tar and gz to indicate that the file is a compressed tar file. Note the significant reduction in the file size. To use tar for this, just identify the file as you would a group of files with a “tar cfz newtarfile filename” command like this: $ tar cfz bigfile.tgz bigfile You can use tar to compress a single file as easily as a group though this offers no particular advantage over using gzip directly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |