TAR 命令

Creating an archive using tar command(建立壓縮文件)

Create linux tar gz (Gzip) archive :

tar -czvf myarchive.tgz mydirectory/linux

tar -czvf myarchive.tar.gz mydirectory/wordpress

We use the -t option to create an linux tar archive
spa

  • c – Creates a new .tar archive file.
  • v – Verbosely(囉嗦地) show the .tar file progress.
  • f – File name type of the archive file.
  • To create a compressed gzip archive file we use the option as z.

Note:that .tgz is the same thing as .tar.gz.code

Create linux tar archive (withouth compresion)

tar -cvf myarchive.tar mydirectory/ip

Create linux tar.bz2 archive

tar -cvfj myarchive.tar.bz2 mydirectory/ci

tar -cvfj myarchive.tb2 mydirectory/it

tar -cvfj myarchive.tbz mydirectory/io

Note:To create highly compressed tar file we use option as j(filter the archive through bzip2).sed

Note: tar.bz2 and tbz is similar as tb2file

Extracting linux tar archive(解壓文件):

Extract linux tar gz (Gzip) archive

tar -xvzf mystuff.tgz

To untar or extract a tar file, just issue following command using option x (extract).

Extract linux simple tar archive

tar -xvf mystuff.tar

Exterct linux simple tar.bz2 archive

tar -xvjf mystuff.tar.bx2

Extract linux tar archive to speciefied directory(文件到目標目錄下)

tar -xvzf filename.tar.gz -C /desired/path

-C directory file

Reference media:

[1]http://linuxbasiccommands.wordpress.com/2008/04/04/linux-tar-command/

[2]http://www.tecmint.com/18-tar-command-examples-in-linux/

相關文章
相關標籤/搜索