Compression and Archives

gzip

Compresses files using gzip.

gzip compresses individual files. It is often used with tar because tar handles directories and file collections.

Syntax
gzip [options] file...

Arguments explained

  • file is the file to compress.
  • -k keeps the original file.
  • -d decompresses, like gunzip.
  • -r recurses into directories.

Common examples

Compress a log
gzip -k app.log

Creates app.log.gz while keeping app.log.

Compress tar output
tar -cf - project | gzip > project.tar.gz

Streams a tar archive through gzip.

gzip Command
FieldDetails
Commandgzip
CategoryCompression and Archives
Primary useCompresses files using gzip.
Syntaxgzip [options] file...