CISER header image
Cornell University Cornell University CISER

CISER Computing Basics

How to Use the CISER Research Nodes:   Compression with GZIP

USING THE GZIP / GUNZIP UTILITY:

  1. Go to Start->Programs->Accessories->Command Prompt to open a command prompt window.
command prompt image
  1. In the command prompt window, change the directory to where the files you want to compress are. For example, if your files are in the "U:\Users\ikh1\temp" directory, type "cd U:\Users\ikh1\temp" (and press <Enter> on the keyboard).   NOTE: If the command prompt begins with a different drive letter such as "C:\", you'll need to type in the drive letter and a colon such as U: and press <Enter> on the keyboard before typing in the full directory.
change dir image
  1. To see the files in the current directory, type "dir". To compress all these files using gzip, type "gzip * " (gzip <asterisk>). When the prompt reappears, type "dir" again. Notice that all the files now have a ".gz" extension, and their file sizes are much smaller.  
    NOTE:
    If you can't see the ".gz" extension in your windows folders, then you can change a folder option to make it visible:  open "My Computer", go to "Tools->Folder Options..." and choose the "View" tab. Make sure the "Hide extensions for known file types" box is unchecked, click on the "Apply to All Folders" button, and then click on "OK
    ".
gzip image
  1. When you need to work with these files again, follow steps 1 & 2 above, and then type "gunzip * ". All the files in the directory will be returned to their original size.
gunzip image


Notes:

  • It isn't necessary to compress all the files in the directory. When typing the command line, you can use a file name in place of the asterisk to gzip or gunzip just one file. You can also gzip or gunzip a group of files with similar names using wildcards. For more information about wildcards, please see: http://kb.iu.edu/data/ahsf.html.
  • To gzip/gunzip files recursively (i.e. when you want to also compress all the files in all the sub-directories), you can add the " -r " option: "gunzip -r * ".
  • While a file is gzipped, it's possible to see it using "zcat". For example, to look at the gzipped file, "uncod.dat.gz", type "zcat uncod.dat.gz | more". It's important to pipe the output to "more" to get one screen at a time, or the entire file will run through the command window at once. (the pipe "|" character is usually located in the upper [shift] position of the backslash \ key.)
zcat image

zcat pipe image

To scroll through the output one screen at a time, press the spacebar. To stop the output and return to the command prompt, press <CTRL>C.