unzip -d: Extract Into a Target Directory
unzip -d extracts the archive contents into the directory you name, creating it if needed.
By default unzip writes into the current directory. -d keeps the extraction contained, which matters when a job juggles several archives.
What it does
unzip -d <dir> extracts all entries under the given directory, creating it (and any parents) if it does not exist. The archive internal paths are recreated beneath that directory.
Common usage
unzip artifact.zip -d ./out
# overwrite into a target directory quietly
unzip -o -q artifact.zip -d /tmp/extractOptions
| Flag | What it does |
|---|---|
| -d <dir> | Extract into this directory (created if missing) |
| -o | Overwrite without prompting |
| -q | Quiet output |
| -j | Junk paths, extract files flat |
In CI
The -d argument goes after the archive name in the conventional order: unzip archive.zip -d dir. Extracting into a clean directory avoids clobbering unrelated files and makes cleanup a single rm of that directory. Combine with -o so a re-run does not stall on the overwrite prompt.
Common errors in CI
"checkdir error: cannot create <dir> ... Permission denied" means the target path is not writable; extract under /tmp or a workspace you own. "cannot create extraction directory" usually means a parent path component is a file, not a directory, or the filesystem is read-only. If files land in the current directory instead, the -d flag or its argument was misplaced.