Google Code Prettify - 輕量級的語法上色工具

星期二, 8月 18, 2015

How to create and extract zip, tar, tar.gz and tar.bz2 files in Linux

Quick Note: If you’re looking for the Windows version of this tutorial, you can find it at How to Open tar.gz Files in Windows.
use the zip format for files that I might need to share with Windows users.
I like to use the tar.gz format for files that I would only use on my Mac and Linux machines.

ZIP

# zip -r archive_name.zip directory_to_compress
# unzip archive_name.zip

TAR

tar -cvf archive_name.tar directory_to_compress
tar -xvf archive_name.tar.gz
This will extract the files in the archive_name.tar archive in the current directory. Like with the tar format you can optionally extract the files to a different directory:
tar -xvf archive_name.tar -C /tmp/extract_here/

TAR.GZ

# tar -zcvf archive_name.tar.gz directory_to_compress
# tar -zxvf archive_name.tar.gz

This will extract the files in the archive_name.tar.gz archive in the current directory. Like with the tar format you can optionally extract the files to a different directory:
tar -zxvf archive_name.tar.gz -C /tmp/extract_here/

TAR.BZ2

# tar -jcvf archive_name.tar.bz2 directory_to_compress
# tar -jxvf archive_name.tar.bz2 -C /tmp/extract_here/
http://www.simplehelp.net/2008/12/15/how-to-create-and-extract-zip-tar-targz-and-tarbz2-files-in-linux/