Unix Shell - Why we always make tar files and zip in unix environment

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > January 2006 > Why we always make tar files and zip in unix environment





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Why we always make tar files and zip in unix environment
Prince of Code

2006-01-19, 2:57 am

Hi all,
This is my first post on this group.

Pls give ur valuble idea for my following question

In Unix systems to make compressed file ( ZIP file in windows ) we need
to tar and then zip it

but in windows we simply zip it. Is TARing a file is a must if so what
is the reasson or can we do

only ZIPing without TARing.

Looking for a elobrate & clear explanation , some kind of web refrence
will be of greate help.

Thankzzz

Regards
Prince Of Code

Stephane CHAZELAS

2006-01-19, 2:57 am

2006-01-18, 22:41(-08), Prince of Code:
> Hi all,
> This is my first post on this group.
>
> Pls give ur valuble idea for my following question
>
> In Unix systems to make compressed file ( ZIP file in windows ) we need
> to tar and then zip it


No, in Unix, we archive the files (put them together in one
file) then compress it (make its size smaller).

> but in windows we simply zip it.


No, we compact them, it's generally the term used to archive and
compress at the same time. winzip archives and compress at the
same time.

> Is TARing a file is a must if so what is the reasson or can we
> do


Archiving is a must if you want to end up with one file out of
several. If not, you can compress every file without making an
archive of them.

> only ZIPing without TARing.


You'd need to define "ZIPing". If you mean compacting, then it's
archiving and compressing which either a combination of tar+gzip
or tar+compress or tar+bzip2 or zip or arc... can do.

If you mean "compressing", then gzip or bzip2 or compress will
do, but that's not what winzip does on Windows (winzip on
windows archives and compresses).

--
Stéphane
Alvin SIU

2006-01-19, 2:57 am

Prince of Code wrote:
> Hi all,
> This is my first post on this group.
>
> Pls give ur valuble idea for my following question
>
> In Unix systems to make compressed file ( ZIP file in windows ) we need
> to tar and then zip it
>
> but in windows we simply zip it. Is TARing a file is a must if so what
> is the reasson or can we do
>
> only ZIPing without TARing.
>
> Looking for a elobrate & clear explanation , some kind of web refrence
> will be of greate help.
>
> Thankzzz
>
> Regards
> Prince Of Code
>


Hi,

"tar" seems cannot compress file.
In unix, compressing a file needs the "compress" command
to get a .Z file
Another way is to use gzip.

I use "tar" to put many files together in one file.

The reason are:

1. You can put many file in different directories into 1 file
and then send/distribute to others

2. For every month, I used to "tar" all those log files into one file
and then compress the tar file into a backup directory.
This tar file will be deleted 6 month later.

3. "tar" related files into one files. For example, put all
the the programs, manual, help files, etc into one tar file
Then, these many tar files will form a version-control series.

These are my uses of tar files.
Manybe others have some more usages of tar files.


Alvin SIU
Barry Margolin

2006-01-19, 8:11 am

In article <1137652894.650586.317540@g44g2000cwa.googlegroups.com>,
"Prince of Code" <princeofcode@gmail.com> wrote:

> Hi all,
> This is my first post on this group.
>
> Pls give ur valuble idea for my following question
>
> In Unix systems to make compressed file ( ZIP file in windows ) we need
> to tar and then zip it
>
> but in windows we simply zip it. Is TARing a file is a must if so what
> is the reasson or can we do
>
> only ZIPing without TARing.
>
> Looking for a elobrate & clear explanation , some kind of web refrence
> will be of greate help.


The general philosophy of Unix is to have lots of tools that each do one
job, and then connect them together when you want to perform more
complex operations. So there's one tool that combines multiple files
into an archive file, and a separate tool that compresses files. If you
want a compressed archive, you simply use them both.

This also gives you options for how you connect them. One way is to
combine all the files into an archive, and then compress that result.
Alternatively, you could compress each individual file, and then combine
these compressed files into an archive.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Prince of Code

2006-01-19, 8:11 am

Thankzzz a lot for all replies. Its really encouraging. Keep up this
spirit.


Prince of Code

Bruce Barnett

2006-01-19, 6:24 pm

"Prince of Code" <princeofcode@gmail.com> writes:

> In Unix systems to make compressed file ( ZIP file in windows ) we need
> to tar and then zip it


No you don't. Not with GNU tar.
Do it in one step, if you want to.

NO COMPRESSION: tar cf archive.tar files*
COMPRESS: tar cfZ archive.tar.Z files*
GZIP: tar cfz archive.tar.gz files*
BZIP: tar cfj archive.tbz files*

You can even use your own compression program.

--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.
William

2006-01-20, 6:03 pm

"Prince of Code" <princeofcode@gmail.com> wrote in message
news:1137652894.650586.317540@g44g2000cwa.googlegroups.com...
> Hi all,
> This is my first post on this group.
>
> Pls give ur valuble idea for my following question
>
> In Unix systems to make compressed file ( ZIP file in windows ) we need
> to tar and then zip it
>
> but in windows we simply zip it. Is TARing a file is a must if so what
> is the reasson or can we do


You can just zip it in unix, too. You might have to install
a zip utility (I use info-zip's version), but it isn't hard
and zip (esp. info-zip) offers a lot of benefits that tar
doesn't. We dropped the use of tar in installs because zip
is much more consistent, robust, and eliminates the extra
steps. (The archives can be read by winzip, too, which is a
plus given our mixed environment.)

Tar is ubiquitous, though, so if you simply can't count on
unzip being around, or can't supply it yourself, then it is
the fallback.

-Wm


-Wm



No_One

2006-01-21, 2:49 am

On 2006-01-20, William <Reply@NewsGroup.Please> wrote:
>
> You can just zip it in unix, too. You might have to install
> a zip utility (I use info-zip's version), but it isn't hard
> and zip (esp. info-zip) offers a lot of benefits that tar
> doesn't. We dropped the use of tar in installs because zip
> is much more consistent, robust, and eliminates the extra
> steps. (The archives can be read by winzip, too, which is a
> plus given our mixed environment.)


Tar does not compress files, it simply archives the files and file
structure, gzip or bzip2 do the compression. Gzip can be called with the
tar command without using a pipe.

I seem to recall, from my windows days, that winzip, the purchased version,
does recognize tar.gz file and, IIRC, tgz files.

ken

William

2006-01-22, 6:10 pm

"No_One" <no_one@no_where.com> wrote in message
news:slrndt3dq3.93p.no_one@localhost.localdomain...
> On 2006-01-20, William <Reply@NewsGroup.Please> wrote:
>
> Tar does not compress files, it simply archives the files and file
> structure, gzip or bzip2 do the compression. Gzip can be called
> with the tar command without using a pipe.


I didn't mean to infer that tar alone compresses files, I meant
it has shortcomings as an archive utility. Gnu tar is an
improvement, but at the cost of portability so you might as
well just switch to something actually designed for the purpose,
and which does the right thing by default (and compresses).

> I seem to recall, from my windows days, that winzip, the
> purchased version, does recognize tar.gz file and, IIRC,
> tgz files.


Sort of. It uncompresses to a tar file in a temp location then
displays the tar contents. I've never actually tried to use it
to modify a tar file's contents through winzip - I can't say it
wouldn't work, therefore. Winzip's format is directly compatible,
ignoring a few OS quirks like permissions, including the archive
comment string (which pops up in a Window under winzip).

-Wm




Timothy Larson

2006-01-22, 6:10 pm

I think it's worth mentioning that WinZip compresses the individual
files, then archives them into one file. This is less efficient than
archiving first (tar) followed by compression (gzip/bzip2/compress) -
with a larger initial file you can make better use of repeated patterns
in the compression stage.

Tim
DaveG

2006-01-22, 6:10 pm

Sometime on Wed, 18 Jan 2006 22:41:34 -0800, Prince of Code scribbled:

> Hi all,
> This is my first post on this group.
>
> Pls give ur valuble idea for my following question
>
> In Unix systems to make compressed file ( ZIP file in windows ) we need
> to tar and then zip it
>
> but in windows we simply zip it. Is TARing a file is a must if so what
> is the reasson or can we do
>
> only ZIPing without TARing.
>
> Looking for a elobrate & clear explanation , some kind of web refrence
> will be of greate help.


You choose the tool you prefer or which is best for the job, whichever
platform you use. eg both rar and zip are available on *nix platforms.
Likewise WinRAR, at least, can handle tar and gzip files from *nix.

--
Dave
Beauty is in the eye of the beerholder

No_One

2006-01-23, 2:55 am

On 2006-01-21, William <Reply@NewsGroup.Please> wrote:
>
> I didn't mean to infer that tar alone compresses files, I meant
> it has shortcomings as an archive utility. Gnu tar is an
> improvement, but at the cost of portability so you might as
> well just switch to something actually designed for the purpose,
> and which does the right thing by default (and compresses).


Understood

>
>
> Sort of. It uncompresses to a tar file in a temp location then
> displays the tar contents. I've never actually tried to use it
> to modify a tar file's contents through winzip - I can't say it
> wouldn't work, therefore. Winzip's format is directly compatible,
> ignoring a few OS quirks like permissions, including the archive
> comment string (which pops up in a Window under winzip).


You're probably right...it's been some time since I used windows let along
winzip. I *do* remember, however, shortly after buying the full version of
winzip, I moved all the computers to linux and the $40 or $50 investment was
wasted...that I remember.

ken



William

2006-01-23, 6:13 pm

"William" <Reply@NewsGroup.Please> wrote in message
news:fPedneqGjsrfHk_eRVn-hA@giganews.com...
> "No_One" <no_one@no_where.com> wrote in message
>
> Sort of. It uncompresses to a tar file in a temp location then
> displays the tar contents. I've never actually tried to use it
> to modify a tar file's contents through winzip - I can't say it
> wouldn't work, therefore. Winzip's format is directly compatible,
> ignoring a few OS quirks like permissions, including the archive
> comment string (which pops up in a Window under winzip).


Replace "Winzip's format is" with "Info-zip's format is" up
there. That's what I meant, anyway. -Wm


William

2006-01-23, 6:13 pm

"Timothy Larson" <thelarsons3@cox.net> wrote in message
news:SXMAf.68934$QW2.56078@dukeread08...
> I think it's worth mentioning that WinZip compresses the individual
> files, then archives them into one file. This is less efficient than
> archiving first (tar) followed by compression (gzip/bzip2/compress) -
> with a larger initial file you can make better use of repeated patterns
> in the compression stage.


I was actually talking about using zip on Unix (Winzip was only
mentioned because the resulting archive is compatible with it.)
Using info-zip, I tried some tests.

I zipped and tar+compress-ed a directory of mostly binary files
and here's what I got:
11323085 Jan 23 11:26 x.tar.Z
7822385 Jan 23 11:23 x.zip

The zip file is 40% smaller. Tar+zip was a tiny bit smaller than
a direct zip, but took longer and you lose the benefits of zip's
features when un-archiving.

For a directory that's almost entirely text, they're closer but
zip still wins by a substantial margin:
527699 Jan 23 11:32 y.tar.Z
402906 Jan 23 11:31 y.zip

-Wm






Stephane Chazelas

2006-01-23, 6:13 pm

On Mon, 23 Jan 2006 11:36:35 -0600, William wrote:
> "Timothy Larson" <thelarsons3@cox.net> wrote in message
> news:SXMAf.68934$QW2.56078@dukeread08...
>
> I was actually talking about using zip on Unix (Winzip was only
> mentioned because the resulting archive is compatible with it.)
> Using info-zip, I tried some tests.
>
> I zipped and tar+compress-ed a directory of mostly binary files
> and here's what I got:
> 11323085 Jan 23 11:26 x.tar.Z
> 7822385 Jan 23 11:23 x.zip
>
> The zip file is 40% smaller. Tar+zip was a tiny bit smaller than
> a direct zip, but took longer and you lose the benefits of zip's
> features when un-archiving.
>
> For a directory that's almost entirely text, they're closer but
> zip still wins by a substantial margin:
> 527699 Jan 23 11:32 y.tar.Z
> 402906 Jan 23 11:31 y.zip

[...]

I don't think anybody was thinking of using compress. If you
want to compare things, you should compare

tar + gzip
and
zip

with the same -1...-9 flags.

gzip and zip use the same compression algorithm, so the zipped
size is bound to be greater than the tar+gzipped one, especially
if the archive contains a lot of small files. But that's the
downsize for zip features.

In a tar+gzip file, you can only access its content
sequencially, you can't directly append files to an archive,
and when the file is corrupted you lose data from the corrupted
block to the end to the archive, while zip/unzip can access
archived files sequencially, better recover files from corrupted
archives and add/remove files directly to an archive.

--
Stephane
William

2006-01-23, 6:13 pm

"Stephane Chazelas" <stephane_chazelas@yahoo.fr> wrote in message
news:slrndta6c2.t1j.stephane_chazelas@duey.spider.com...
> On Mon, 23 Jan 2006 11:36:35 -0600, William wrote:
>
> I don't think anybody was thinking of using compress. If you
> want to compare things, you should compare


Actually, the person I was responding to mentioned it as one
of three choices.

>
> tar + gzip
> and
> zip
>
> with the same -1...-9 flags.
>
> gzip and zip use the same compression algorithm, so the zipped
> size is bound to be greater than the tar+gzipped one, especially
> if the archive contains a lot of small files. But that's the
> downsize for zip features.


Not surprisingly, zip and gzip produce essentially the same size
archive when compressing the tar file. The difference seems to be
a bit over 100 bytes which is probably related to info-zip's extra
features.

When compressing 46 mostly binary files (~22.5 MB) the difference
in archive size between info-zip and tar+gzip is a whisper over
0.005% (with either -1 or -9):

8800783 Jan 23 15:50 x-1.zip
8755909 Jan 23 15:50 x-1.tar.gz
44874 Bytes smaller

7741610 Jan 23 15:53 x-9.zip
7702025 Jan 23 15:50 x-9.tar.gz
39585 Bytes smaller

I think zip's worth it :-) -Wm



William

2006-01-24, 6:23 pm

"William" <Reply@NewsGroup.Please> wrote in message
news:9oSdnSBw69TLyUjeRVn-uw@giganews.com...
>
> When compressing 46 mostly binary files (~22.5 MB) the difference
> in archive size between info-zip and tar+gzip is a whisper over
> 0.005% (with either -1 or -9):


Sorry, meant 0.5%, not 0.005% - forgot to shift the decimal.

-Wm


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com