Rozbalení je proces odebrání jednoho komprimovaného archivu a extrahování souborů a složek zevnitř. Protože již máme soubor zip, musíme soubory nejprve extrahovat, což se také nazývá dekomprimace.
Příkaz pro dekomprimaci souboru zip je rozbalení následujícím způsobem:
% unzip --help
UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
Default action is to extract files in list, except those in xlist, to exdir;
file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage).
-p extract files to pipe, no messages -l list files (short format)
-f freshen existing files, create none -t test compressed archive data
-u update files, create if necessary -z display archive comment only
-v list verbosely/show version info -T timestamp archive to latest
-x exclude files that follow (in xlist) -d extract files into exdir
modifiers:
-n never overwrite existing files -q quiet mode (-qq => quieter)
-o overwrite files WITHOUT prompting -a auto-convert any text files
-j junk paths (do not make directories) -aa treat ALL files as text
-C match filenames case-insensitively -L make (some) names lowercase
-X restore UID/GID info -V retain VMS version numbers
-K keep setuid/setgid/tacky permissions -M pipe through "more" pager
See "unzip -hh" or unzip.txt for more help. Examples:
unzip data1 -x joe => extract all files except joe from zipfile data1.zip
unzip -p foo | more => send contents of foo.zip via pipe into program more
unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer Pokud při spuštění příkazu unzip narazíte na níže uvedenou chybu:
unzip: command not found
můžete zkusit nainstalovat rozbalovací balíček podle vaší volby distribuce.
| Distribuce | Příkaz |
|---|---|
| OS X | brew install unzip |
| Debian | apt-get install rozbalit |
| Ubuntu | apt-get install rozbalit |
| Alpine | apk přidat rozbalit |
| Arch Linux | Pacman -S rozbalit |
| Kali Linux | apt-get install rozbalit |
| CentOS | yum install unzip |
| Fedora | dnf install unzip |
| Raspbian | apt-get install rozbalit |
Rozbalte příklady příkazů
1. Testování integrity souboru zip:
$ unzip -t test.zip
Pokud se soubor stáhl s chybami, měli byste jej zkusit stáhnout znovu. Pokud nebyly v archivu zjištěny žádné chyby, můžete pokračovat.
2. Výpis obsahu souboru zip:
$ unzip -l test.zip
3. Rozbalte soubor(y) zip (u více souborů oddělte cesty k souborům mezerami):
$ unzip file(s)
3. Extrahujte soubory zip do zadané cesty:
$ unzip compressed_file(s) -d path/to/put/extracted_file(s)
4. Extrahujte obsah souboru (souborů) ke standardnímu zpracování spolu s názvy extrahovaných souborů:
$ unzip -c file.zip
5. Rozbalte soubor zip vytvořený v systému Windows, který obsahuje soubory s názvy souborů, které nejsou v ASCII (např. čínské nebo japonské znaky):
$ unzip -O gbk file.zipzip:příkaz nenalezen