Show Total Size of Extracted Files in Unrar
While the unrar utility does not have a single native
switch to print a cumulative extracted byte count at the end of the
extraction command, you can easily achieve this output using built-in
listing commands or simple shell commands. This guide explains how to
view the total uncompressed size before extraction, inspect the final
footprint immediately after extracting, and automate the entire process
with a custom command.
Method 1: Check the Total Size Before Extracting
The fastest way to see the total size of all files contained in an
archive is to list its contents using the l (list) or
v (verbose) command.
Run the following command:
unrar l archive.rarAt the bottom of the generated table, unrar prints a
summary row displaying:
- Total number of files
- Total uncompressed size
- Total compressed size
- Compression ratio
If you want to view only the summary line with the total size, pipe
the output through tail:
unrar l archive.rar | tail -n 2Method 2: Display the Size Automatically After Extraction
To extract the files and immediately view the total disk space
consumed by the extracted content, chain unrar with the
du (disk usage) command using the &&
operator.
Run the extraction to a specific directory:
unrar x archive.rar output_dir/ && du -sh output_dir/x: Extracts files with their full directory path.output_dir/: The target extraction folder.&&: Ensures the next command runs only if the extraction succeeds.du -sh: Displays the summary total (-s) in human-readable format (-h).
To view the raw apparent size in bytes rather than block allocation
on disk, use the --apparent-size flag with
du:
unrar x archive.rar output_dir/ && du -sh --apparent-size output_dir/Method 3: Create a Reusable Shell Function
To make unrar display the total extracted size
automatically every time without manually retyping multiple commands,
add a wrapper function to your ~/.bashrc or
~/.zshrc file:
unrar_size() {
local archive="$1"
local dest="${2:-.}"
unrar x "$archive" "$dest" && {
echo -e "\n--- Extraction Complete ---"
echo -n "Total Extracted Size: "
du -sh "$dest" | cut -f1
}
}Apply the changes:
source ~/.bashrcNow you can extract any archive and see the total size printed automatically at the end of the process:
unrar_size archive.rar target_folder