gzip

>Usage

gzip is a command-line utility used to compress files using the gzip compression algorithm, which reduces the file size for easier storage or transfer.

>Synopsis

gzip [option] file

>Options

-c

to stdout: Outputs the compressed data to the standard output (stdout) rather than modifying the original file.

Example 1:

Dots

-zsh

gzip -c file.txt > file.txt.gz


the file file.txt is compressed and redirected to a new file file.txt.gz without modifying the original file

-k

keep original: When you use this option, gzip compresses the file but keeps the original one instead of deleting it after compression.

Example 2:

Dots

-zsh

gzip -k file.txt


after the execution you'll have both text.txt and text.txt.gz (the compressed file)

-r

recursiv: With this option gzip will compress all files within a directory and its subdirectories recursively. Useful to compress multiple files in a directory without needing to specify each file individually

Example 3:

Dots

-zsh

gzip -r dir/


compress all files in the directory/subdirectories and replace each file with the compressed version

-l

list information: Used to list information about a compressed file (.gz), such as original size, compressed size, compression ratio,...

-S

suffix: Allows to specify a costum suffix for the compressed file instead of the default one (.gz), this will not affect the compression

Example 4:

Dots

-zsh

gzip -S .zip file.txt


the argument after -S will replace the default .gz suffix

-t

test: allows to test the integrity of a compressed .gz file without decompressing it. If the file is valid it will generate no output.

>Quiz

Progress: Question ? out of ?

Question Title

Page written by Oliviero Vescovo