Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I use the 7-Zip CLI (7za.exe) on Windows to create .tgz archives, as I use tar zcvf archive.tgz source_files on Linux?

share|improve this question

migrated from stackoverflow.com Sep 26 '11 at 11:30

This question came from our site for professional and enthusiast programmers.

    
OT alert: it beats me why anybody would use 7-zip in any circumstances. Why not winzip? –  Pete Wilson Sep 26 '11 at 11:18
3  
@PeteWilson It's free. –  f.ardelian Sep 26 '11 at 11:21
    
Thanks to whoever moved the question here. My mistake. –  f.ardelian Sep 26 '11 at 11:32
6  
Not the only reason. Supported file formats and features blow winzip out of the water. My reaction is more along the lines of why would anybody not use 7-zip. –  mindless.panda Sep 26 '11 at 13:35

2 Answers 2

up vote 6 down vote accepted

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

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

I'm not sure why the archive.tar is required in the first part, but it is. It doesn't even need to end in .tar, it just needs an archive name to use.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.