![]() To list the contents of a zip file without unzipping it, use the -l option (which stands for "list"). Or perhaps you want to make sure that a file you need is contained within that Zip file. Sometimes you might find yourself looking at a Zip file and not remembering what's in that file. The actual password you type disappears into the ether, unavailable to anyone viewing your shell history. The only part of this that's saved in the shell is zip -e moby.zip *.txt. The difference, however, is that you're prompted to type the password in, so it won't be saved in the history of your shell events. Instead, just use the -e option, which encrypts the contents of your Zip file and also uses a password. It's completely insecure, as you can see in the following example (the actual password is 12345678): $ zip -P 12345678 moby.zip *.txtīecause you had to specify the password on the command line, anyone viewing your shell's history (and you might be surprised how easy it is for other users to do so) can see your password in all its glory. The Zip program allows you to password-protect your Zip archives using the -P option. In tabular format, the results look like this: Updating: paradise_lost.txt (deflated 56%) Updating: paradise_lost.txt (deflated 50%) rw-r-r- scott scott 508925 paradise_lost.txt rw-r-r- scott scott 1236574 moby-dick.txt Let's compare the results of different compression rates. Say you're interested in researching Herman Melville's Moby-Dick, so you want to collect key texts to help you understand the book: Moby-Dick itself, Milton's Paradise Lost, and the Bible's book of Job. The zip command uses a scale from 0 to 9, in which 0 means "no compression at all" (which is like tar, as you'll see later), 1 means "do the job quickly, but don't bother compressing very much," and 9 means "compress the heck out of the files, and I don't mind waiting a bit longer to get the job done." The default is 6, but modern computers are fast enough that it's probably just fine to use 9 all the time. It's possible to adjust the level of compression that zip uses when it does its job. Get the Best Compression Possible with zip Whether you're zipping up a file, several files, or a directory, the pattern is the same: the zip command, followed by the name of the Zip file you're creating, and finished with the item(s) you're adding to the Zip file. $ ls -lFĪdding: edgar_scott/edgar_baby.tif (deflated 12%)Īdding: edgar_scott/young_edgar_scott.tif (deflated 19%)Īdding: edgar_scott/edgar_intl_shoe.tif (deflated 4%) Better to zip up a directory containing those 50 files so when the user unzips it, he's left with a tidy directory instead. If the payload was 50 files, however, the user would end up with files strewn everywhere. ![]() The recipient will unzip grandpa.zip and end up with three individual files. It's not too polite, however, to zip up individual files this way. $ zip grandpa.zip edgar_intl_shoe.tif edgar_baby.tif young_edgar_scott.tifĪdding: edgar_intl_shoe.tif (deflated 4%) rw-r-r- scott scott 1029224 young_edgar_scott.tif rw-r-r- scott scott 1130922 edgar_baby.tif rw-r-r- scott scott 251980 edgar_intl_shoe.tif You can do the same thing for several images. In this case, you shaved off about 200KB on the resulting zip file, or 19%, as zip helpfully informs you. rw-r-r- scott scott 1006K young_edgar_scott.tifĪdding: young_edgar_scott.tif (deflated 19%) Note - When using ls -l, I'm only showing the information needed for each example. That said, computers are so fast nowadays that most users won't notice much of a difference between the times it takes gzip or bzip2 to compress a group of files. Designed to supersede gzip, bzip2 creates smaller files, but at the cost of speed. The bzip2 command is the new kid on the block. If you're sending files back and forth to users of Unix-based machines, gzip is a safe choice. It's found on virtually every Unix-based system in the world, including Linux and Mac OS X, but it is much less common on Windows. Gzip was designed as an open-source replacement for an older Unix program, compress. If you're sending archives out to users and you don't know which operating systems they're using, zip is a safe choice to make. That's because of its almost universal use on Windows, but zip and unzip are well supported among all major (and most minor) operating systems, so things compressed using zip also work on Linux and Mac OS. Note - In fact, you might end up with a bigger file during compression! If the file is already compressed, compressing it again adds extra overhead, resulting in a slightly bigger file.Īll of the archive and compression formats in this chapter - zip, gzip, bzip2, and tar - are popular, but zip is probably the world's most widely used format.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |