compressed using zip gzip bzip2

Problem

You have been sent (or want to download) a zip file. But also want to verify the contents, before decompressing.



Solution

Under UNIX there are a number of ways to compress files, or deal with those that have already been compressed.

See the examples tab.



Example


  • Firstly dealing with files ending with .gz.

    To view the contents of a gzipped file, just use gzip -l filename.gz

    To unzip the file, use gzip -d filename.gz or gunzip filename.gz

    To view the contents of the gzipped file, without decompressing it: gzip -c -d filename.gz.

    To create a gzip – gzip –best filename – or gzip reads from stdin, in the best of UNIX traditions. 🙂 You can also pipe gzip output or redirect it.

  • Next unzip.

    To view the contents of a zipped file, just use zipinfo filename.zip

    To unzip the file, use unzip filename.zip.

    To view the contents of the gzipped file, without decompressing it: unzip -c filename.gz.

    To create a zip – zip filename – or zip reads from stdin.

  • Lastly bzip.

    To decompress the file, use bunzip2 filename.bz2.

    To view the contents of the bzipped file, without decompressing it: bzcat filename.bz2.

    To create a zip – bzip2 filename – or zip reads from stdin.



Reference

[tags]gzip, zip, bzip2, UNIX Coding School[/tags]



Leave a Reply

Your email address will not be published. Required fields are marked *