Παρασκευή 3 Δεκεμβρίου 2021

TAR vs GZIP vs zip

 TAR vs GZIP vs zip


tar in itself just bundles files together (the result is called a tarball), 

while zip applies compression as well. 

Usually you use gzip along with tar to compress the resulting tarball,

 thus achieving similar results as with zip 

1. tar,zip  command examples

Create a new tar archive.


$ tar cvf archive_name.tar dirname/



Extract from an existing tar archive.

$ tar xvf archive_name.tar


View an existing tar archive.

$ tar tvf archive_name.tar

-------------------------------

GZIP

Gzip is one of the most popular compression algorithms that allow you to reduce the size of a file and keep the original file mode, 

ownership, and timestamp.

Gzip uses the Lempel-Ziv algorithm used in zip and PKZIP. The amount of compression obtained depends on the size of the input and 

the distribution of common substrings. Typically, text such as source code or English is reduced by 60-70%. Compression is generally 

much better than that achieved by LZW (as used in compress), Huffman coding (as used in pack), or adaptive Huffman coding (compact).

For example, to get maximum compression, you would run:


gzip -9 filename


-- -- --

zip unzip

ZIP is an archiving and compression tool, all in one, while Gzip needs the help of Tar command to archive files.


install:$ sudo apt install zip unzip

$zip myfile.zip filename.txt

zip -r filename.zip folder

zip -r filename.zip folder1 folder2

Extracting files from zip file 


Unzip will list, test, or extract files from a ZIP archive, commonly found on Unix systems. The default behavior (with no options) is to extract into the current directory (and sub-directories below it) all files from the specified ZIP archive.




Syntax :

$unzip myfile.zip 

Δεν υπάρχουν σχόλια: