I have a tar.gz file that is about 1.39GB. I want to estimate the unzipped size before I actually extract it to avoid filling up my disk. This is for my work and I can only use my work PC (Windows 11) for it. I'm using PowerShell 7. What is the command to accomplish this?
I found many answers under unix/linux, like this one.
I guess in unix/linux, the solve is tar -cz data_dir | wc -c
But what is the equivalent in PowerShell 7 (Windows 11)?
You can use the built-in tar.exe
to list the content of your gzip archive:
tar.exe -t -v -f test.tar.gz
You can then parse the output and add up the sizes:
$tarOutput = tar.exe -t -v -f test.tar.gz
$size = ($tarOutput | %{(-split $_)[4]} | Measure-Object -Sum).Sum
$size