GNU Gzip examples

Last updated:
Table of Contents

WIP Alert This is a work in progress. Current information is correct but more content may be added in the future.

Compress file

$ gzip my-file.txt

Archive file is created and the original file is removed.

$ ls

Extract gz file

gunzip is installed along with gzip:

$ gunzip file.txt.gz

The file is extracted in the current directory and the archive file is removed:

$ ls

Extract file to another directory

Use gunzip file.gz -c > path/to/extracted/file

$ gunzip file.txt.gz > foo/bar/extracted-file.txt

The original archive file is kept (showing output with tree):

$ tree
├── file.txt.gz
└── foo
    └── bar
        └── extracted-file.txt

See also:

Dialogue & Discussion