REF: http://www.cyberciti.biz/howto/question/general/compress-file-unix-linux-cheat-sheet.php
zip to avoid compatibility problems
------------------------------------
zip squash.zip file1 file2 file3
Then you can extract the original files like this:
unzip squash.zip
-------------------------------------------------------------------------
To use gzip
------------
To compress a file, at a shell prompt, type the following command:
gzip filename.ext
The file will be compressed and saved as filename.ext.gz.
Whenever possible, each file is replaced by one with the extension .gz.
To expand a compressed file, type:
gunzip filename.ext.gz
The filename.ext.gz is deleted and replaced with filename.ext.
-------------------------------------------------------------------------
To use bzip2
-------------
bzip2 filename
bzip2 file1 file2 file3 /usr/work/school
The file will be compressed and saved as filename.bz2.
Whenever possible, each file is replaced by one with the extension .bz2.
To expand the compressed file, type the following command:
bunzip2 filename.bz2
The filename.bz2 is deleted and replaced with filename.
-------------------------------------------------------------------------
To use Tar
-----------
To create a tar file, type
---------------------------
tar -cvf foo.tar /home/mine/work /home/mine/school
tar -cvf foo.tar file1.txt file2.txt file3.txt
To list the contents of a tar file, type:
tar -tvf foo.tar
To extract the contents of a tar file, type:
tar -xvf foo.tar
The tar command does not compress files automatically. You can compress tar files with:
tar -czvf foo.tar
Compressed tar files are conventionally given the extension .tgz and are compressed with gzip.
To expand a compressed tar file type:
tar -xzvf foo.tgz
---------------------------------------------------------------------------------------
Linux compression and decompression commands are given in this post. These commands are very useful as you need to compress large files and then decompress them. The command for doing this is simple so you can directly apply it.
ReplyDeletesap test