Overview
unzip takes files out of a .zip archive. Without options it unpacks everything into the current folder, so use -d to choose a folder. -l lists the contents, -p prints a file to the screen and -t tests the archive.
Background
unzip is the Info-ZIP program, and the macOS build is UnZip 6.00 with changes by Apple. The tool tested here is that build.
Examples
Print one file from an archive to the screen, without unpacking it:
printf data > f.txt && zip -q a.zip f.txt && unzip -p a.zip f.txt
Unpack into a folder with -d:
printf data > f.txt && zip -q a.zip f.txt && unzip -q a.zip -d out && cat out/f.txt
List only the names with -Z1:
printf data > f.txt && zip -q a.zip f.txt && unzip -Z1 a.zip
Test that the archive is not damaged:
printf data > f.txt && zip -q a.zip f.txt && unzip -t a.zip | tail -n 1
List the contents with sizes, ending with a summary line:
printf data > f.txt && zip -q a.zip f.txt && unzip -l a.zip | tail -n 1
Options
-d
Unpack into this folder.
-l
List the contents.
-p
Print the files to standard output.
-t
Test the archive.
-o
Replace existing files without asking.
-q
Quiet.
Common mistakes
Unpacking an archive from someone else can write files over yours, or outside the folder with ../ in a name on old versions, so list it with -l first and unpack with -d into a new folder. When a file exists, unzip asks whether to replace it; -o replaces without asking and -n never replaces. A .zip made on another system can have names in another character set. Passwords given with -P are visible in the process list.
Portability
The options above are the same on macOS and Linux with Info-ZIP. The table of the list and the text of messages differ a little between versions, so the example that shows the summary line is compared with blanks collapsed. The examples were executed on UnZip 6.00 (macOS build). The Common examples were executed on UnZip 6.00 (macOS build) (see the development guide for the exact check).
About upstream unzip
This is the upstream Info-ZIP unzip program. It is one program everywhere; some Linux distributions need the package installed.
References
Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.