7zr on the Command Line
Compressing and extracting archives with the 7-Zip CLI.
7zr is a command-line version of the 7-Zip compression tool. It supports a variety of compression formats, including 7z, ZIP, GZIP, BZIP2, and more. Here are some basic usage examples:
Compressing files or folders
bash
7zr a [archive_name].7z [file_or_folder_to_compress]- The
aargument means "add to archive" (the compression operation). [archive_name].7zis the archive file name you specify;.7zis the default 7-Zip compression format extension.[file_or_folder_to_compress]is the path to the actual file or folder you want to compress.
For example, to compress the test folder in the current directory:
bash
7zr a test.7z testExtracting files
bash
7zr x [archive_name].7z -o[output_directory]- The
xargument means "extract" (the decompression operation). [archive_name].7zis the archive you want to extract.-o[output_directory]specifies the target folder to extract into.
For example, to extract test.7z into an extracted folder in the current directory:
bash
7zr x test.7z -oextractedListing the contents of an archive
bash
7zr l [archive_name].7z- The
largument lists the contents of the archive (the file listing).
For example, to list the contents of test.7z:
bash
7zr l test.7zThese commands will help you compress and decompress files with 7zr from the command line. Before using it, remember to make sure you have installed the 7-Zip tool and the corresponding command-line version.