gzip command compresses single or multiple files. The compressed file ending with the extension (.gz), generally size of compressed file will be less than the size of the original file.

The gzip command uses a deflate algorithm, deflate algorithm a lossless data compression that creates smaller file sizes to make file transfer much faster.

gzip only reduces the size of a file and keeps the original file mode, ownership, and timestamp. It means compressed data remains the same after decompressing. To decompress the files, gunzip command is used and your original file will be back.

In this tutorial, you will learn about gzip command and uses of gzip command with examples

Benefits of compressed file

gzip command is used to compress the files. The benefits of compressed files are the following

  • To save disk space. gzip command compresses the file and creates smaller file sizes.
  • To save bandwidth. Smaller file sizes reduce the bandwidth and also make it easy to transfer large amounts of data over the internet.

Syntax for gzip command

gzip [options] file1 file2 file3.......

Uses of gzip command with examples

cat abc.txt

cat filename

Compress the files

Simply using gzip without any options compresses the file and replaces the files with the same file name with a .gz extension. gzip can be used to compress a single file or multiple files.

For Single file

gzip filename
gzip abc.txt

gzip filename

gzip -v def.txt

gzip -v filename-1

For multiple files

gzip file1 file2 file3 .....
gzip 123.txt 456.txt

gzip command file1 file2 multiple files

gzip -k ghi.txt

gzip command -k filename

gzip -L def.txt.gz

gzip command -L zipfile

gzip -d 123.txt.gz

gzip command -d filename

 

gzip -d 456.txt.gz abc.txt.gz def.txt.gz ghi.txt.gz

gzip command -d file1 file2 multiple files

gzip -k ghi.txt

gzip command -k filename

gzip -L def.txt.gz

gzip command -L zipfile

 

 

Sharing is Caring
Scroll to Top