Skip to content
shellmap

unzipExtract files from a ZIP archive — the read side of zip across all 5 shells

Equivalents in every shell

Bashunix
unzip archive.zip

Info-ZIP `unzip` — POSIX-portable, ships in nearly every Linux distro, on macOS, and on every BSD. `-d <dir>` extracts to a target directory; `-o` overwrites without prompting; `-l` lists contents without extracting; `-j` strips directory paths (flatten). For non-ASCII filenames (Japanese, Cyrillic), `-O <encoding>` (e.g. `-O CP932`) decodes legacy Windows-encoded ZIPs.

Zshunix
unzip archive.zip

Same Info-ZIP binary on Linux. macOS ships its own slightly older `unzip` build by default — for unicode filename support pass `-O UTF-8` (the default on Linux). `brew install unzip` updates to the latest Info-ZIP.

Fishunix
unzip archive.zip

Same external. Fish has no built-in archive primitive. To extract multiple ZIPs in a loop: `for z in *.zip; unzip -o $z -d (basename $z .zip); end` — note the `(...)` for command substitution (no `$(...)` in fish).

PowerShellwindows
Expand-Archive -Path archive.zip -DestinationPath ./out

Native cmdlet since PowerShell 5.0 (Windows 10 / Server 2016). `-Force` overwrites; `-DestinationPath` defaults to the current directory if omitted. The underlying implementation is `System.IO.Compression.ZipFile.ExtractToDirectory` — fast on the common path, but does NOT preserve Unix file modes or symlinks (those are ZIP-format extensions Info-ZIP supports but `Expand-Archive` ignores).

cmd.exewindows
tar -xf archive.zip

Windows 10 1803+ ships `bsdtar` as the system `tar.exe`, which transparently extracts ZIP archives in addition to tarballs. Older Windows: no native unzipper — use `powershell -c Expand-Archive` or call the COM-side `Shell.Application` (`CopyHere` from the zip namespace).

Worked examples

Extract a ZIP to a specific directory

Bash
unzip archive.zip -d /tmp/out
PowerShell
Expand-Archive -Path archive.zip -DestinationPath /tmp/out -Force
cmd.exe
tar -xf archive.zip -C C:\tmp\out

List archive contents without extracting

Bash
unzip -l archive.zip
PowerShell
[IO.Compression.ZipFile]::OpenRead((Resolve-Path archive.zip)).Entries | Select FullName, Length
cmd.exe
tar -tf archive.zip

Extract just one file from inside a ZIP

Bash
unzip archive.zip path/inside/file.txt -d ./out
PowerShell
[IO.Compression.ZipFile]::OpenRead((Resolve-Path archive.zip)).GetEntry("path/inside/file.txt").Open()
cmd.exe
tar -xf archive.zip path/inside/file.txt

Gotchas

  • `Expand-Archive` does NOT preserve Unix file permissions or symbolic links stored in the ZIP. A ZIP created on Linux with `zip -y` (preserve symlinks) will, after `Expand-Archive`, contain regular files containing the symlink target as text. Use Info-ZIP `unzip` (e.g. via WSL or `choco install unzip`) when symlinks matter.
  • `tar -xf archive.zip` works in Windows 10 1803+ ONLY because the bundled bsdtar speaks the ZIP format. Older Windows ships GNU tar (no ZIP support) or no tar at all. Check `tar --version`: bsdtar shows "bsdtar" in the banner.
  • ZIP filename encoding is historically unspecified — pre-2007 ZIPs from Asian-locale Windows machines often used CP932 / CP949 / GB18030 instead of UTF-8. `unzip -O CP932 archive.zip` decodes them correctly. `Expand-Archive` has no encoding override and produces mojibake on these archives.
  • Path-traversal CVEs: malicious ZIPs may contain entries with `../../` paths or absolute paths that escape the extraction root ("zip slip"). Info-ZIP `unzip` (since 6.0) and `Expand-Archive` both reject these, but rolling your own with `[IO.Compression.ZipFile]::ExtractToDirectory` in PowerShell 4 or below was vulnerable — verify the target path stays inside the destination before extracting if you call the .NET API directly.
  • On macOS, double-clicking a ZIP in Finder runs Archive Utility, which is NOT `unzip` — it stores files' resource forks as `__MACOSX/._*` companion files. Re-zipping that directory with `zip -r` re-includes the cruft. Pass `-x "__MACOSX/*" -x "*.DS_Store"` when re-packaging.

WSL & PowerShell Core notes

pwsh`Expand-Archive` is cross-platform (pwsh 6+ on Linux and macOS) but on Unix targets it still drops permissions and symlinks — the .NET ZIP layer is the limit, not the host OS. For full-fidelity ZIP extraction on Unix pwsh, shell out: `& unzip archive.zip`. The corresponding compress side is `Compress-Archive`, which is similarly POSIX-mode-lossy.
WSLInfo-ZIP `unzip` is `apt install unzip` (most distros do not ship it by default). Extracting a Windows-side ZIP from inside WSL is fine across the DrvFs boundary: `unzip /mnt/c/Users/me/Downloads/file.zip -d ~/extracted`. Extracting INTO `/mnt/c/...` is also fine but ~3× slower than extracting into the native WSL filesystem because every file metadata write crosses the 9P boundary.

Common tasks using unzip

Related commands