$ zip -q bin bin/* $
If you’re zipping a listing that incorporates subdirectories, these subdirectories, however not their contents will probably be added to the zip file until you add the -r (recursive). Right here’s an instance:
$ zip bin bin/* updating: bin/FindFiles (deflated 54%) updating: bin/shapes (deflated 63%) updating: bin/shapes2 (deflated 62%) updating: bin/shapes3 (deflated 45%) updating: bin/NOTES/ (saved 0%)
Right here’s an instance that provides -r and, consequently, consists of the NOTES subdirectory’s information within the bin.zip file is it creating.
$ zip -r bin bin/* updating: bin/FindFiles (deflated 54%) updating: bin/shapes (deflated 63%) updating: bin/shapes2 (deflated 62%) updating: bin/shapes3 (deflated 45%) updating: bin/NOTES/ (saved 0%) including: bin/NOTES/finding_files (deflated 5%) including: bin/NOTES/shapes_scripts (deflated 35%)
Utilizing encryption passwords
So as to add a password that may should be used to extract the contents of a zipper file, use a command just like the one proven under. Discover that it prompts twice for the password, although it doesn’t show it.
$ zip -e -r bin bin/* Enter password: Confirm password: updating: bin/FindFiles (deflated 54%) updating: bin/shapes (deflated 63%) updating: bin/shapes2 (deflated 62%) updating: bin/shapes3 (deflated 45%) updating: bin/NOTES/ (saved 0%) updating: bin/NOTES/finding_files (deflated 5%) updating: bin/NOTES/shapes_scripts (deflated 35%)
Extracting file from a zipper file
To extract the contents of a zipper file, you’ll use the unzip command. Discover that, as a result of the zip file under was encrypted with a password, that password must be provided to extract the contents.
$ unzip bin.zip Archive: bin.zip [bin.zip] bin/FindFiles password: inflating: bin/FindFiles inflating: bin/shapes inflating: bin/shapes2 inflating: bin/shapes3 creating: bin/NOTES/ inflating: bin/NOTES/finding_files inflating: bin/NOTES/shapes_scripts
If you wish to extract the contents of a zipper file to a distinct listing, you don’t have to cd to that listing first. As an alternative, you possibly can merely add the -d choice adopted by the goal listing to specify the brand new location.
$ unzip bin.zip -d /tmp Archive: bin.zip [bin.zip] bin/FindFiles password: inflating: /tmp/bin/FindFiles inflating: /tmp/bin/shapes inflating: /tmp/bin/shapes2 inflating: /tmp/bin/shapes3 creating: /tmp/bin/NOTES/ inflating: /tmp/bin/NOTES/finding_files inflating: /tmp/bin/NOTES/shapes_scripts
You’ll be able to extract a single file from a zipper file if you happen to specify its title as listed within the zip file. Right here’s an instance command the place the unique file (perhaps it’s been broken indirectly) is changed after confirming that that is what you need.