Zipping a File or Directory with gzip


Zipping a File or Directory with gzip

If you want to compress only a single file or directory, you might choose gzip, rather than compress. gzip is more efficient, so you wind up with smaller files than you do with compress. As Code Listing 13.10 shows, you use gzip much the same way that you use compress.

To Zip a File or Directory with gzip:

1.

ls -l z*

At the shell prompt, use ls -l to confirm the name of the file or directory you want to zip. In this example, we're looking for z (as in zipadeedoodah) files.

2.

gzip zipadeedoodah.tar

Type gzip followed by the name of the file or directory to gzip. The zipped file will replace the unzipped version and will have a new .gz extension.

Tips

  • Another utility used for compressing files is bzip (bzip2, actually). You can find more information about it at http://www.bzip.org/. It's quite powerful and quickly gaining popularity.

  • You can tar a group of files and then compress the single file using gzip.

  • If you want to keep a copy of the original, unzipped file, try gzip -c filetogzip > compressed.gz.

  • If the compressed files will be accessed by someone using Windows, you should consider using zip, which is discussed later in this chapter. Although gzip is more convenient in the Unix world, gzip is not the same as good old Pkzip or .zip files used in DOS and Windows.


Code Listing 13.10. Use gzip to zip up those bulky tar files.

[ejr@hobbes compression]$ ls -l z* -rw-r-r-   1 ejr    users    501760 Jul 27 10:22 zipadeedoodah.tar [ejr@hobbes compression]$ gzip zipadeedoodah.tar [ejr@hobbes compression]$ ls -l z* -rw-r-r-   1 ejr    users    239815 Jul 27 10:22 zipadeedoodah.tar.gz [ejr@hobbes compression]$ 




Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net