Compress files with Gzip and Zip in CentOS

Gzip
Type the following command to compress a file at a shell prompt

gzip filename.ext

-> The file will be compressed and saved as filename.ext.gz

Type the following command to expand a compressed file

</code><code>gunzip  filename.ext.gz</code><code>

-> The filename.ext.gz is deleted and replaced with filename.ext

Type the following command to compress multiple files at a shell prompt

</code><code>gzip filename.gz file1 file2 file3</code><code>

->  this command will compress file1, file2, file3 and put them in filename.gzip.

Zip
Type the following command to compress a file at a shell prompt

</code><code>zip -r filename.zip files</code><code>

->  filename represents the file you are creating and files represents the files you want to put in the new file

Type the following command to expand a compressed file

</code><code>unzip  filename.zip</code><code>

Type the following command to compress multiple files at a shell prompt

</code><code>zip filename.zip file1 file2 file3</code><code>

-> this command will compress file1, file2, file3 and put them in filename.zip

If you add directory to multiple files

</code><code>zip filename.zip file1 file2  file3 /user/work/school</code> <code>

->  this command will compress file1, file2, file3, the contents of the /user/work/school directory and put them in filename.zip

%d bloggers like this: