What is the best Unix compression command?

Status
Not open for further replies.

no_mad

Full Member level 5
Joined
Dec 10, 2004
Messages
271
Helped
30
Reputation
60
Reaction score
11
Trophy points
1,298
Location
Naboo
Activity points
2,489
Unix compression command

Hi..

If i want to compress a folder, what is the best unix command shall I use, gzip or tar??

Please show me the correct command tht I need to use

Thanx
 

Re: Unix compression command

Hi
to compress the file use
>tar cvzf file.tar.gz file
and to uncompress it
>tar xvzf file.tar.gz
if tar doesnt work, try gtar or guntar
regards
 

Unix compression command

Hi sharma,

Is this command only for file compression??

Because i have a folder with so many files. Thus, I want to compress this folder. Can I do that using tar command?
 

Unix compression command

Hi

Assume you have a folder named "test" in /home/myhome/test
use the following commands:

Code:
%cd /home/myhome
%tar cvf test.tar ./test
....
.... results in test.tar

Code:
%gzip -c test.tar > test.tar.gz

You may replace "gzip" with "compress" commnad if "gzip" is not installed in your system or you have an older version of Sun Solaris.

For decompression:
use one of the following commnad:

Code:
% gzip -dc test.tar.gz | tar xvf -


tnx
 

    no_mad

    Points: 2
    Helpful Answer Positive Rating
Re: Unix compression command

you know, tar converts a sub-structure of the file system into a single file, since all the compression commands in unix work on single files. after tar you can use gzip or bzip2 to compress the single file output of the tar.
 

Re: Unix compression command

Hi,

-----------
Is this command only for file compression??

Because i have a folder with so many files. Thus, I want to compress this folder. Can I do that using tar command?
-----------

Yes, You can use this command to compress any folder also.
 

Re: Unix compression command

As you've mentioned, these compression commands work ONLY on SINGLE files... if you want to compress a DIRECTORY (unix calls them DIRECTORIES) you've got to use TAR command to store all of the files and sub-directories of that directory in a single file. then the compression command comes in and can comress the file. also the decompression command is the same, except for the "-d" option which will cause the tool to work "backwards" and decompress the file. then you've got to use TAR command with the "-x" option to make it restore the directory structure from that file into the disk. please note that all of the options in late linuces can be issued without the dash at the beginning but the legacy unices which does not use the GNU getopt, require the "-" at the beginning of (each) option.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…