Concept Flow - zip and unzip
Start with files/folders
Use zip command
Create .zip archive
Use unzip command
Extract files from archive
End
This flow shows how files are compressed into a zip archive and then extracted back using unzip.
zip archive.zip file1.txt file2.txt unzip archive.zip
| Step | Command | Action | Output/Result |
|---|---|---|---|
| 1 | zip archive.zip file1.txt file2.txt | Compress files into archive.zip | adding: file1.txt (deflated 50%) adding: file2.txt (deflated 45%) |
| 2 | unzip archive.zip | Extract files from archive.zip | Archive: archive.zip inflating: file1.txt inflating: file2.txt |
| 3 | unzip archive.zip -l | List contents of archive.zip | Archive: archive.zip Length Date Time Name -------- ---- ---- ---- 1024 2024-06-01 10:00 file1.txt 2048 2024-06-01 10:00 file2.txt -------- 3072 2 files |
| 4 | unzip archive.zip -d extracted_folder | Extract files into extracted_folder | Archive: archive.zip inflating: extracted_folder/file1.txt inflating: extracted_folder/file2.txt |
| 5 | zip -r archive.zip folder/ | Compress folder recursively | adding: folder/file1.txt (deflated 50%) adding: folder/file2.txt (deflated 45%) |
| 6 | unzip archive.zip -t | Test integrity of archive.zip | No errors detected in compressed data of archive.zip |
| 7 | unzip archive.zip -o | Extract and overwrite existing files | Archive: archive.zip inflating: file1.txt inflating: file2.txt |
| 8 | unzip archive.zip -x file2.txt | Extract all except file2.txt | Archive: archive.zip inflating: file1.txt |
| 9 | zip archive.zip | No files specified | zip error: Nothing to do! (try: zip archive.zip -r .) |
| 10 | unzip nonexist.zip | Try to unzip non-existing archive | unzip: cannot find or open nonexist.zip, nonexist.zip.zip or nonexist.zip.ZIP. |
| 11 | Execution ends as commands complete |
| Variable | Start | After Step 1 | After Step 2 | After Step 4 | After Step 5 | Final |
|---|---|---|---|---|---|---|
| archive.zip | does not exist | created with file1.txt and file2.txt | exists with compressed files | exists with compressed files | updated with folder contents | exists with latest contents |
| file1.txt | exists | unchanged | extracted from archive | extracted in extracted_folder | unchanged | unchanged |
| file2.txt | exists | unchanged | extracted from archive | extracted in extracted_folder | unchanged | unchanged |
| extracted_folder/ | does not exist | does not exist | does not exist | created with extracted files | exists | exists |
zip: compress files/folders into a .zip archive unzip: extract files from a .zip archive Use 'zip archive.zip files...' to create archive Use 'unzip archive.zip' to extract Options: -d to extract to folder, -l to list, -x to exclude files
zip command do in Linux?zipzip command is used to compress files into one archive to save space or organize files.unzip extracts files, ls lists files, and rm deletes files, so these are not correct.archive.zip including all files in the folder docs recursively?-r option tells zip to include folders and their contents recursively.zip -r archive.zip docs correctly creates the archive including all files inside docs. Other options are incorrect or for unzip.unzip -l archive.zip?-l option in unzip-l option lists the files inside the zip archive without extracting them.unzip archive.zip but get an error saying "cannot find or open archive.zip". What is the most likely cause?unzip is correct to extract files; no -r option is needed. Corruption would give a different error.backup.zip that includes all files and folders inside project, but exclude all .log files. Which command will do this correctly?-r option includes folders recursively, and -x '*.log' excludes all .log files.Pass the test and this pattern moves unknown