首页 > 其他 > 详细

TAR 命令

时间:2014-05-05 23:40:41      阅读:733      评论:0      收藏:0      [点我收藏+]

Create linux tar gz (Gzip) archive   (创建压缩文件)

tar -czvf myarchive.tgz mydirectory/

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

  • 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

Create linux simple tar archive (withouth compresion)

tar -cvf myarchive.tar mydirectory/

Create linux tar.bz2 archive

tar -cvfj myarchive.tar.bz2 mydirectory/

Note:To create highly compressed tar file we use option as j.

Extracting linux tar archive:

Extract linux tar gz (Gzip) archive
tar -xzvf 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 -jxvf mystuff.tar.bx2

Extract linux tar archive to speciefied directory
tar -xvzf filename.tar.gz -C /desired/path

And now let us shortly explain this command

Usage: tar [OPTION]… [FILE]…



Let us check the option used in this example


-c, –create                      create a new archive
-z, –gzip, –ungzip        filter the archive through gzip
-v, –verbose                   verbosely list files processed
-f, –file=ARCHIVE          use archive file or device ARCHIVE


-C directory file
Performs a chdir  operation on directory and performs the c (create) or r (replace) operation on file .
In c and r mode, this changes the directory before adding the following files. In x mode, change directories after opening the archive but before extracting entries from the archive.


Testing / viewing your archive


tar -tvf myarchive.tar
tar -tzvf myarchive.tgz


Here we used the – t opton
-t, –list                           list the contents of an archive


————————————————-


Go ahead, try out these commands and stay tuned; we will come up with more doccumentation on linux tar command

The article source: http://linuxbasiccommands.wordpress.com/2008/04/04/linux-tar-command/

 

TAR 命令,布布扣,bubuko.com

TAR 命令

原文:http://www.cnblogs.com/cnguoyu123/p/3704549.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!