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
link|improve this question

feedback

2 Answers

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.

link|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
feedback

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
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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