1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

Example uses of the command "gzip"

A Brief Introduction

By

Businesswoman in suit working on computer at office
Nicolas Hansen/E+/Getty Images
The following examples illustrate typical uses of the command gzip for compressing (or "packaging") a file into an "archive file".

gzip archivefile1.txt
This command compresses the file archivefile1.txt and replaces it with the compressed version named "archivefile1.txt.gz".

If you want to keep the uncompressed version, you can use the -c option, which writes to standard out, and then re-direct (">") standard out to a file like this:


gzip -c archivefile1.txt > archivefile1.txt.gz
The ".gz" file extension is commonly used by the compression program gzip, which is the counter part of gunzip.

You can use the "-r" option to recursively compress all the files under the specified directory:


gzip -r documents_folder

For all available options of the gzip command see the man page.

  1. About.com
  2. Technology
  3. Linux
  4. Linux / Shell Commands
  5. Example uses of the Linux shell Command "gzip"

©2014 About.com. All rights reserved.