List of common decompress & compress tools in unix

For my future reference:  (整理自互联网)

check folder size:

du -sh *

————

1. 7-zip:  (.7z file)

官网下载地址:http://www.7-zip.org/download.html
源文件项目地址:http://sourceforge.net/projects/p7zip/,目前最新版为9.20.1。
执行以下命令下载安装:

wget http://nchc.dl.sourceforge.net/project/p7zip/p7zip/9.20.1/p7zip_9.20.1_src_all.tar.bz2
tar -jxvf p7zip_9.20.1_src_all.tar.bz2
cd p7zip_9.20.1
make
make install

使用7zip的命令是7za。
安装完成后的使用方法:
7za {a|d|l|e|u|x} 压缩包文件名 {文件列表或目录,可选}

a 向压缩包里添加文件或创建压缩包,如向001.7z添加001.jpg,执行:7za a 001.7z 001.jpg;将001目录打包执行:7za a 001.7z 001;
d 从压缩里删除文件,如将001.7z里的001.jpg删除,执行:7za d 001.7z 001.jpg
l 列出压缩包里的文件,如列出001.7z里的文件,执行:7za l 001.7z
e 解压到当前目录,目录结构会被破坏,如001.rar内有如下目录及文件123/456/789.html,
执行:7za e 001.rar,目录123和456及文件789.html都会存放在当前目录下。
x 以完整路径解压。

zip文件解压中文文件乱码问题,由于zip文件中没有声明其编码,所以在Linux上使用unzip解压以默认编码解压,中文文件名会出现乱码。

————–

2. tar:  (decompress)

  1. Type at the command prompt
    tar xvzf file-1.0.tar.gz – to uncompress a gzip tar file (.tgz or .tar.gz)
    tar xvjf file-1.0.tar.bz2 – to uncompress a bzip2 tar file (.tbz or .tar.bz2)
    tar xvf file-1.0.tar – to uncompressed tar file (.tar)
    • x = eXtract, this indicated an extraction c = create to create )
    • v = verbose (optional) the files with relative locations will be displayed.
    • z = gzip-ped; j = bzip2-zipped
    • f = from/to file … (what is next after the f is the archive file)
  2. The files will be extracted in the current folder (most of the times in a folder with the name ‘file-1.0’).

3. tar: (compress)

To tar all .cc and .h files into a tar file named foo.tgz use:

    tar cvzf foo.tgz *.cc *.h

This creates (c) a compressed (z) tar file named foo.tgz (f) and shows the files being stored into the tar file (v). The .tgz suffix is a convention for gzipped tar files, it’s useful to use the convention since you’ll know to use z to restore/extract.

It’s often more useful to tar a directory (which tars all files and subdirectories recursively unless you specify otherwise). The nice part about tarring a directory is that it is untarred as a directory rather than as individual files.

   tar cvzf foo.tgz cps100

will tar the directory cps100 (and its files/subdirectories) into a tar file named foo.tgz.

————–

4. (.bz2) file (Perfect for single file compression)

download bzip2: http://www.bzip.org/downloads.html

parallel bzip2 (MPI version): http://compression.ca/mpibzip2/

bzip2 -d filename.bz2

After decompression, original file will be deleted

—————

Ref:

http://how-to.wikia.com/wiki/How_to_untar_a_tar_file_or_gzip-bz2_tar_file

https://www.cs.duke.edu/~ola/courses/programming/tar.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s