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.

I sometimes get confused by the varying command line options I need to run common Unix archiving and compression software (e.g. gzip, bzip2, zip, tar).

Is there a program out there that can just Do What I Mean for common cases? For example:

program --compress --gzip foobar
program --extract foobar.tar.bz2
program --extract foo.zip
share|improve this question

2 Answers 2

up vote 8 down vote accepted

As example 7z.

7z a -tgzip foobar.gz foobar
7z e foobar.gz

Where a - add files to archive, -t{Type} - Set type of archive (7z, zip, gzip, bzip2 or tar), e - extract files from archive. More information man 7z.

share|improve this answer
You shouldn't need the -t option most of the time -- 7-zip will guess archive type from common file extensions if possible. –  afrazier Jun 22 '11 at 23:01

tar, when configured correctly, can do this all (except the unzip maybe) easily.

tar --create --gzip --file out.tar.gz in in2 in3
# same thing
tar -czf out.tar.gz in in2 in3

tar --extract --file in.tar
tar -xf in.tar

This will work for gzipped and bzip2ed files as well. (Assuming you actually have such programs installed.)

Edit: Oh yeah, forgot about the unzip. That's not included in tar presumably because of patent reasons or such. Simply use the unzip application to extract those:

unzip in.zip
share|improve this answer

Your Answer


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.