gunzip
Archives
Usage
gunzip [-k] <file.gz>Unpacks a .gz back to the original file and removes the .gz on success, so `-k` keeps it, `-f` is needed when a file of that name already exists, and `-c` streams the contents out without ever writing them to disk, exactly like zcat.
Common flags
| Flag | Meaning |
|---|---|
| -k | Keep the .gz file instead of removing it on success. |
| -c | Write to stdout and touch nothing on disk, the same as zcat. |
| -f | Overwrite an existing output file, which it otherwise refuses to do. |
| -t | Test the file instead of unpacking it. |
| -l | List the sizes inside. |
Examples
gunzip backup.sql.gzLeaves backup.sql; the .gz file is removed.
gunzip -c dump.sql.gz | psql mydbRestore without ever writing the uncompressed file to disk.
Bundling and compressing are separate jobs: tar bundles, gzip shrinks, and .tar.gz is both.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does gunzip do?
Unpacks a .gz back to the original file and removes the .gz on success, so `-k` keeps it, `-f` is needed when a file of that name already exists, and `-c` streams the contents out without ever writing them to disk, exactly like zcat.
Q. How do I type it?
gunzip [-k] <file.gz> — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
5 are listed here; the full set is in man gunzip. This command sits under Archives.
Related commands
man page: man gunzip