zaagan
3/3/2018 - 4:29 AM

Compression Decompression

Compress | Decompress files using different methodologies



# [ GZIP ]
# Compress all files
tar -czf zipName.tar.gz .     

# Compress a folder
tar -czf zipName.tar.gz folderName

# c: Create an archive.
# z: Compress the archive with gzip.
# v: Display progress in the terminal while creating the archive, also known as “verbose” mode. 
#    The v is always optional in these commands, but it’s helpful.
# f: Allows you to specify the filename of the archive.

# Compress with exclusion
 tar -cvzf zipName.tar.gz folderName --exclude=folderName/fileName1 --exclude=folderName/fileName2
 tar -cvzf zipName.tar.gz folderName --exclude=*.txt


# [ BZip2 ]
tar -cjvf zipName.tar.bz2 folderName

# j: Compress the archive with bzip2.

# Decompress 
tar xvf zipName.tar
tar xzvf zipName.tar.gz
tar xjvf zipName.tar.bz2



# [ ZIP ]
# Zip Individual Files
zip ZipName fileName1 fileName2

# Zip All Files in current folder
zip -r zipName.zip .

# Zip with partial excluding
zip -r zipName.zip . -x fileName


# [ UNZIP ]
# Unzip to the current location
unzip ZipFileName.zip 

# Unzip to a different location
unzip ZipFileName -d DirectoryName