How do I use 7-Zip CLI for Windows to create .tar.gz archives?

If you'd like to do it in a one-liner:

7za.exe a -ttar -so -an source_files | 7za.exe a -si archive.tgz

The -an switch tells 7-Zip not to parse the archive_name command line parameter that's normally required.


If you're just compressing 1 file into the tarball then 7za a archive.tgz source_file will work.

If you want to add lots of files to the tar then you need to do it in two steps: Create the tar 7za a archive.tar source_files Then compress it 7za a archive.tgz archive.tar

And, optionally, delete the 'temporary' tar del archive.tar


Now Windows supports a native tar command:

tar -cvzf output.tar.gz input_dir

https://techcommunity.microsoft.com/t5/containers/tar-and-curl-come-to-windows/ba-p/382409

Found it here.