Installation
The CLI is installed with the gem:
gem install excavateThe executable excavate will be available in your PATH.
Commands
extract (default)
Extract files from an archive.
excavate extract [OPTIONS] ARCHIVE [FILES...]Or simply:
excavate ARCHIVE [FILES...]Exit Codes
Excavate uses specific exit codes for different outcomes:
| Code | Name | Description |
|---|---|---|
0 |
| Extraction completed successfully |
1 |
| An unexpected error occurred |
2 |
| Target file or directory already exists |
3 |
| Target directory is not empty |
4 |
| Requested file not found in archive |
Examples
Basic Extraction
# Extract to auto-created directory
excavate package.zip
# Creates ./package/ directory
# Extract MSI installer
excavate setup.msi
# Extract TAR.GZ
excavate archive.tar.gzRecursive Extraction
# Extract MSI with nested CAB files
excavate --recursive setup.msi
# Short form
excavate -r package.pkg
# Process directory of archives
excavate -r archives/Selective Extraction
# Extract specific files
excavate data.tar.gz config/settings.json data/users.csv
# Extract from nested archive
excavate -r package.msi fonts.zip/Arial.ttf
# Multiple files from nested archives
excavate -r installer.exe data.cab/config.ini data.cab/README.txtFilter-Based Extraction
# Extract all TrueType fonts
excavate --filter "**/*.ttf" fonts.zip
# Extract configuration files
excavate --filter "etc/**/*.conf" backup.tar
# Multiple extensions
excavate --filter "**/*.{png,jpg}" assets.zip
# Specific directory
excavate --filter "src/**/*.rb" project.tar.gzOutput
On success, the CLI prints the target directory or files:
$ excavate package.zip
Successfully extracted to package/
$ excavate --filter "*.ttf" fonts.zip
Successfully extracted to Arial.ttf, Verdana.ttf
$ excavate -r installer.msi
Successfully extracted to installer/Error Messages
$ excavate package.zip
Target directory `package` is not empty.
$ excavate data.zip missing.txt
File `missing.txt` not found.
$ excavate unknown.dat
Could not unarchive `unknown.dat`.
$ excavate --filter "*.pdf" fonts.zip
Filter `*.pdf` matched no file.Shell Script Integration
The CLI is designed for easy scripting:
Batch Processing
#!/bin/bash
set -e
# Extract all installers in a directory
for msi in installers/*.msi; do
excavate -r "$msi"
doneError Handling
#!/bin/bash
excavate package.zip
exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "Extraction successful"
elif [ $exit_code -eq 3 ]; then
echo "Directory not empty, cleaning..."
rm -rf package/
excavate package.zip
else
echo "Extraction failed with code $exit_code"
exit 1
fi