About Me

My photo

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/E/B d-- s:++>: a-- C++(++++) UL++ P! L++ E--- W+++ N+++ w PS+ PE- !tv
b+++ G++ e++ h
------END GEEK CODE BLOCK------

Tuesday, July 20, 2004

How to Create a tar file

Suppose you have
1.c
2.c
3.c
To create tar file of name *codes.tar*, the command is
tar -cf codes.tar 1.c 2.c 3.c

c option stands for create.
f for file

tar -czf codes.tgz 1.c 2.c 3.c will create a compressed tarred file.

Now for extracting these is this command
tar xvf codes.tar
tar xvzf codes.tgz

f should go along with filename.




9 comments:

Kannappan said...

I remember having used tar -cvf

One more related thought/query :

for files ending with .Z, am able to open them with zcat
However for files ending with .gz, am unable to read them using gzcat. am trying to find why not. Currently reading them by gunzip {filename} and then cat the unzipped file


Also have to check what is the algo used by unix...tar command. i hope there will be one standard algo. I hav seen most compression tools use the compression algo called...lempel Ziv algo...tried manually simulating lempel some rudimentary compression of Lempel Ziv some 5 0r 6 months back....I shall post later of some basics I learnt while doing that process....

phoe6 said...

First off, kudos for trying with the compression algorithm. I would like to listen more on them.
lempelZivWelchpage at NIST seems to be a good starting point.
I was just checking with various resources. This page bears the index to two papers and also has link to a C source( did not compile for me, need to check why).
But anyways, a good starting point.
---
*spent somemore time on tar gz, Z etc.
from comp.compression FAQ
What is this 'tar' compression program?
tar is not a compression program. It just combines several files
into one, without compressing them. tar file are often compressed with
'compress', resulting in a .tar.Z file.
.....

First came compress (and uncompress) which gave an output with .Z extension.
Then gzip was created as a improvement and replacement of compress.

*zcat will uncompress the files that have the correct magic number ( created using compress?) whether they have .Z extension or not.

*gzcat is a local alias to zcat ( could not find gzcat in my system FC2)

*so for filename.gz.I guess it should be gunzip -c filename.gz and if thereis filename.Z, as per the above both zcat filename.Z and gzcat filename.Z should work.
How does it go?

phoe6 said...

The C Source compiled.
The intial reason for non compilation was:
error:too few arguments to the function exit.it was like exit();
changing to exit(0); worked.
but the weird thing I am observing is:
compressed file size is greater than orginal one.
120 bytes vs 96 bytes.
But the program is a demonstration, gives compressed output as test.lzw as well as uncompressed output as test.out.

Kannappan said...

Thanks for the updates.

Regarding the 120 and 96 bytes weird thing. yeah I believe it happens for smaller data. Me too observed similar things while doing for 1, 2 and 3 bit numbers.

Kannappan said...

trying to find out at what number of bytes ... the real compression takes place....

Kannappan said...

and why the real compression starts from that number of bytes only.....

Kannappan said...

Hey am abt to make a rudimentary flawed compression algo- The Whitefield One bit algo. :o)
Give me any number of bits ...it will be compressed to one bit...and if needed decompressed back to the original info..but with a big flaw....

Whitefield term is borrowed after bangalore's Whitefield..Heard that Intel is abt to name a chip as Whitefield...which is being developed in b'lore as reported by my friend. read this register news
http://www.theregister.co.uk/2004/05/01/intel_whitefield_uncovered/

phoe6 said...

Wow! Both are really interesting.
Lets see which Whitefield comes to shore and attains the world domination first :)

Kannappan said...

hey hey...dont scare with all world domination stuff....
this algo is so junk...that sure our ancestors would hav thought of such things much earlier......concept used is XOR....Though i dont consider this in anyway as an achievement...am happy..crazy happy to work on such small minute things which dont have any major impact on anything......huh....thanks bytheby for the intrest