Situatie
The gzip command is a common way of compressing files within Linux.
By default when you compress a file or folder using the gzip command it will have the same file name as it did before but with the extension .gz.
Solutie
How to Compress a File Using gzip
The simplest way to compress a single file using gzip is to run the following command:
To compress a file called mydocument.odt run the following command:
Some files compress better than others. For example documents, text files, bitmap images, and certain audio and video formats such as WAV and MPEG compress very well. Other file types such as JPEG images and MP3 audio files do not compress at all well and the file may actually increase in size after running the gzip command against it.
How to Decompress a File Using the gzip Command
Use the following command to decompress a gzip archive:
To decompress the mydocument.odt.gz file use the following command:
Get Some Stats About How Much Space You Saved
The whole point of compressing files is about saving disk space or to reduce the size of a file prior to sending it over a network. The gzip command provides the kind of statistics you require when checking for compression performance.
The information returned by the above command is as follows:
- Compressed size
- Uncompressed size
- Ratio as a percentage
- Uncompressed filename
Leave A Comment?