Example Uses of the Linux gzip Command

Rezolvare problema (Fix IT)

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:

gzip filename
To compress a file called mydocument.odt run the following command:
gzip mydocument.odt

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:

gzip -d filename.gz
To decompress the mydocument.odt.gz file use the following command:
gzip -d mydocument.odt.gz

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.

To get the list of statistics run the following command:
gzip -l filename.gz
The information returned by the above command is as follows:
  • Compressed size
  • Uncompressed size
  • Ratio as a percentage
  • Uncompressed filename

Tip solutie

Permanent

Voteaza

(13 din 28 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?