Total Pageviews

Thursday, April 12, 2012

compression and archiving

On unix, compression is separate from archiving.Tar is an archiver, meaning it would archive multiple files into a single file but without compression.
tar command is short for tape archiving
To combine multiple files and/or directories into a single file, use the following command:
tar -cvf file.tar inputfile1 inputfile2
Replace inputfile1 and inputfile2 with the files and/or directories you want to combine. You can use any name in place of file.tar, though you should keep the .tar extension. If you don't use the  f  option, tar assumes you really do want to create a tape archive instead of joining up a number of files. The  v  option tells tar to be verbose, which reports all files as they are added.
To separate an archive created by tar into separate files, at the shell prompt, enter:
tar -xvf file.tar
gzip (the GNU file compression program).Gzip compress the size of the given files using Lempel-Ziv coding (LZ77)
tar -cvzf file.tar.gz inputfile1 inputfile2
Here, the  z  option tells tar to zip the archive as it is created. To unzip such a zipped tar file, enter:
tar -xvzf file.tar.gz
Lastly, the extensions .tgz and .tar.gz are equivalent; they both signify a tar file zipped with gzip.

Bzip2 is a compression format that has better compression than both zip, and gzip.bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by bzip command (LZ77/LZ78-based compressors).
bzip2 *.jpg
bzip2 -d mydata.doc.bz2

zip is a compression and file packaging utility for Unix/Linux. Each file is stored in single .zip {.zip-filename} file with the extension .zip.
zip data.zip *.doc
unzip file.zip

    tar xvzf file-1.0.tar.gz - for uncompress a gzip tar file (.tgz or .tar.gz)
    tar xvjf file-1.0.tar.bz2 - for uncompress a bzip2 tar file (.tbz or .tar.bz2)
    tar xvf file-1.0.tar - for uncompressed tar file (.tar)

    x = eXtract, this indicated an extraction ( c = create to create )
    v = verbose (optional) the files with relative locations will be displayed.
    z = gzip-ped; j = bzip2-zipped

No comments:

Post a Comment