patool
Extract, create, test, and list archive contents
TLDR
Extract an archive
Create an archive
List contents of an archive
Compare the contents of two archives and display the differences in the standard output
Search for a string inside the contents of an archive
SYNOPSIS
patool [OPTIONS] COMMAND [ARCHIVE_OR_FILES...]
Common commands:
patool extract [OPTIONS] <ARCHIVE>: Extracts files from an archive.
patool create [OPTIONS] <ARCHIVE> <FILES_OR_DIR...>: Creates an archive from files or directories.
patool list [OPTIONS] <ARCHIVE>: Lists the contents of an archive.
patool test [OPTIONS] <ARCHIVE>: Tests the integrity of an archive.
patool compare [OPTIONS] <ARCHIVE1> <ARCHIVE2>: Compares the contents of two archives.
PARAMETERS
-o
Specify the output directory for extraction. If not specified, files are extracted to the current directory.
-v, --verbose
Increase verbosity level, showing more details about the operation.
--dry-run
Perform a trial run with no changes made to the system. Useful for testing commands.
--force
Overwrite existing files without prompting during extraction or creation.
--path=
Specify a path inside the archive to operate on (e.g., extract only a specific folder).
--recurse
Recurse into subdirectories when creating an archive (for supported formats).
--flat
Extract all files into a single flat directory, ignoring the original directory structure within the archive.
--program=
Explicitly specify the path to the backend program to use for the operation (e.g., '/usr/bin/tar').
--assume-type=
Force patool to assume a specific archive type (e.g., 'zip', 'tar.gz'), overriding automatic detection.
--compress-program=
Specify a custom program to use for compression of specific archive types (e.g., for .tar.gz, use gzip).
--decompress-program=
Specify a custom program to use for decompression of specific archive types (e.g., for .tar.gz, use gunzip).
--do-not-delete-input
Prevent patool from deleting input archives after a successful extraction or creation operation.
DESCRIPTION
patool is a Python-based command-line tool that provides a unified interface for managing various archive formats. Instead of requiring users to remember specific commands and options for tar, zip, rar, 7z, gzip, bzip2, xz, and many others, patool automatically detects the archive type and utilizes the appropriate backend program to perform the requested operation. This greatly simplifies tasks like creating, extracting, listing, testing, and comparing archives across different formats.
It aims to make archive management portable and user-friendly by abstracting away the complexities of diverse archiving utilities, ensuring a consistent user experience regardless of the underlying archive technology. patool itself does not contain the compression/decompression algorithms; it acts as a wrapper around the actual tools that must be installed on the system.
CAVEATS
patool relies heavily on the availability of underlying archive tools (e.g., tar, zip, unrar, p7zip) on the system. If the required backend tool for a specific archive format is not installed, patool will not be able to process that format. While patool simplifies usage, it might not expose every fine-grained option available in the individual backend tools, limiting advanced or very specific operations. Its Python-based nature and external calls can sometimes result in slower performance compared to directly invoking native archiving utilities for very large operations.
SUPPORTED FORMATS
patool supports a wide range of archive formats including, but not limited to, .zip, .tar, .tar.gz, .tar.bz2, .tar.xz, .7z, .rar, .iso, .dmg, .rpm, .deb, .exe (self-extracting archives), and many others, provided the corresponding backend utility is installed on the system.
DEPENDENCIES
patool itself is a Python script, but its functionality is entirely dependent on external, command-line archiving programs installed on the system. For example, to handle .zip files, you need zip and unzip; for .rar, you need unrar; for .7z, p7zip; and for .tar.gz, tar and gzip. Users must ensure these tools are present in their system's PATH for patool to function correctly.
HISTORY
patool was created by Christoph Gohlke as a cross-platform solution to standardize archive management across different operating systems and numerous archive formats. Developed in Python, its primary motivation was to provide a simple, unified command-line interface that abstracts the complexities of individual archiving utilities. Its development focused on ensuring portability and ease of use, allowing users to perform common archive operations without needing to know the specific syntax or existence of various backend tools.