If the internal path is stage components/file.txt, extract it as:
unzip archive.zip "stage components/*"
To extract just the directory structure: If the internal path is stage components/file
unzip archive.zip "stage components/"
Assuming listing shows:
Archive: archive.zip
Length Date Time Name
--------- ---------- ----- ----
0 2025-01-01 12:00 stage/components/file1.txt
0 2025-01-01 12:00 stage/components/file2.txt
Correct extraction:
unzip archive.zip "stage/components/*"
If error persists, use unzip -j to junk paths: To extract just the directory structure:
unzip archive
unzip -j archive.zip "stage/components/*" -d ./target/
strace -e openat unzip archive.zip "stage/*" 2>&1 | grep -i "zip"
When writing shell scripts that extract specific parts of a ZIP, follow these best practices: Assuming listing shows: Archive: archive
sudo dtruss unzip archive.zip "stage/*" 2>&1 | grep -i "open"
This reveals exactly what filenames unzip is looking for inside the ZIP's central directory.