Skip to content
Latchkey

7z x: Extract and List Archives in CI

7z x extracts an archive preserving directory structure, while 7z e flattens it and 7z l lists contents without extracting.

On the read side, 7z handles many formats a single tool otherwise could not. In CI, x with -o and -y extracts non-interactively into a workspace.

What it does

7z x extracts an archive with full paths into the current directory or the -o target. 7z e extracts every file into one directory, dropping paths. 7z l lists entries and sizes. -y answers all prompts yes, which is essential for non-interactive CI.

Common usage

Terminal
7z x artifact.7z -o./out -y         # extract with paths, no prompts
7z x -p"$PASS" secrets.7z           # extract an encrypted archive
7z e bundle.7z -o./flat             # flatten into one dir
7z l release.7z                     # list before extracting

Options

Flag / verbWhat it does
xExtract with full paths
eExtract flat (ignore stored paths)
lList archive contents
-o<dir>Output directory (no space after -o)
-p<password>Password for an encrypted archive
-yAssume yes to all queries (overwrite, etc.)
-aoaOverwrite all existing files without asking

In CI

Always pass -y (and -aoa when re-extracting) so 7z does not stop on an overwrite prompt and hang the job. Use -o./dir with no space. 7z reads zip, tar, gz, bz2, xz, and rar (with the rar codec), so it can be a single extractor in a minimal image after installing p7zip-full.

Common errors in CI

"7z: command not found" means p7zip is missing. "Can not open the file as archive" means an unsupported or corrupt file. "Wrong password?" means -p is missing or wrong. A job hanging on extract usually means a prompt is waiting; add -y. For .rar, p7zip may report "Unsupported Method" without the rar codec; use unrar instead.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →